A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

YTD Subquery is not including December why?



 
 
Thread Tools Display Modes
  #1  
Old November 26th, 2009, 02:06 AM posted to microsoft.public.access.queries
jeromez
external usenet poster
 
Posts: 2
Default YTD Subquery is not including December why?

Hi Allen:

I created a query with a subquery to sum the hours worked by period (i.e.,
month) and then YTD hours next to the month hours.

However, it's not entirely working for me and it's driving me crazy.

The query gives me by Dept and period the ytd hours in the field labeled
"YTDHours"

One final glitch remains:

I added one record for December (period 12) and it is "blank" in the
YTDHours column.

Why doesn't it pick up December?

Any help would be greatly appreciated!

if it would be helpful to look at the database I can send it if you send me
an email.
or I can past the code.
  #2  
Old November 26th, 2009, 03:47 AM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default YTD Subquery is not including December why?

On Wed, 25 Nov 2009 18:06:01 -0800, jeromez
wrote:

Hi Allen:

I created a query with a subquery to sum the hours worked by period (i.e.,
month) and then YTD hours next to the month hours.

However, it's not entirely working for me and it's driving me crazy.

The query gives me by Dept and period the ytd hours in the field labeled
"YTDHours"

One final glitch remains:

I added one record for December (period 12) and it is "blank" in the
YTDHours column.

Why doesn't it pick up December?

Any help would be greatly appreciated!

if it would be helpful to look at the database I can send it if you send me
an email.
or I can past the code.


Please post the code (the SQL view of the query) and a description of the
structure of your table. If the table has a separate field for each month
("period"...?) then it's not correctly designed.
--

John W. Vinson [MVP]
  #3  
Old November 27th, 2009, 11:52 AM posted to microsoft.public.access.queries
jeromez
external usenet poster
 
Posts: 2
Default YTD Subquery is not including December why?

one more note:

I'm only using two departments in the example:

1. 405 which is the same as 4051
2. 455 which is the same as 4552

I initially started with 405 and 455 and thought it might be easier to
understand the example if added an additional number to the dept. but didn't
change all the data in the example before I posted and it was permanently
etched in time :P
  #4  
Old December 2nd, 2009, 01:15 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default YTD Subquery is not including December why?

Actually DateSerial will handle month 13 easily.

DateSerial(2009,13,1) will return January 1, 2010 (the 13th month of 2009 is
the first month of 2010)

It will also handle
DateSerial(2009,13,32) and return February 1, 2010

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Daryl S wrote:
Jeromez -

The following cannot evaluate to a date, since there aren't 13 months in a
year:

A.RepDate DateSerial(Year(Tbl_Hours_Actual.RepDate),
Month(Tbl_Hours_Actual.RepDate)+1,1)) AS YTDHours

Try converting it to this:

A.RepDate DateSerial(Year(Tbl_Hours_Actual.RepDate),
Month(Tbl_Hours_Actual.RepDate)+1,1)) AS YTDHours

to this:

A.RepDate IF(Month(Tbl_Hours_Actual.RepDate) = 12,
DateSerial(Year(Tbl_Hours_Actual.RepDate)+1,
,1,0),DateSerial(Year(Tbl_Hours_Actual.RepDate),
Month(Tbl_Hours_Actual.RepDate)+1,1)) AS YTDHours

(this is untested, but you get the idea...)

  #5  
Old December 2nd, 2009, 01:15 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default YTD Subquery is not including December why?

Actually DateSerial will handle month 13 easily.

DateSerial(2009,13,1) will return January 1, 2010 (the 13th month of 2009 is
the first month of 2010)

It will also handle
DateSerial(2009,13,32) and return February 1, 2010

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Daryl S wrote:
Jeromez -

The following cannot evaluate to a date, since there aren't 13 months in a
year:

A.RepDate DateSerial(Year(Tbl_Hours_Actual.RepDate),
Month(Tbl_Hours_Actual.RepDate)+1,1)) AS YTDHours

Try converting it to this:

A.RepDate DateSerial(Year(Tbl_Hours_Actual.RepDate),
Month(Tbl_Hours_Actual.RepDate)+1,1)) AS YTDHours

to this:

A.RepDate IF(Month(Tbl_Hours_Actual.RepDate) = 12,
DateSerial(Year(Tbl_Hours_Actual.RepDate)+1,
,1,0),DateSerial(Year(Tbl_Hours_Actual.RepDate),
Month(Tbl_Hours_Actual.RepDate)+1,1)) AS YTDHours

(this is untested, but you get the idea...)

  #6  
Old December 2nd, 2009, 01:15 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default YTD Subquery is not including December why?

Actually DateSerial will handle month 13 easily.

DateSerial(2009,13,1) will return January 1, 2010 (the 13th month of 2009 is
the first month of 2010)

It will also handle
DateSerial(2009,13,32) and return February 1, 2010

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

Daryl S wrote:
Jeromez -

The following cannot evaluate to a date, since there aren't 13 months in a
year:

A.RepDate DateSerial(Year(Tbl_Hours_Actual.RepDate),
Month(Tbl_Hours_Actual.RepDate)+1,1)) AS YTDHours

Try converting it to this:

A.RepDate DateSerial(Year(Tbl_Hours_Actual.RepDate),
Month(Tbl_Hours_Actual.RepDate)+1,1)) AS YTDHours

to this:

A.RepDate IF(Month(Tbl_Hours_Actual.RepDate) = 12,
DateSerial(Year(Tbl_Hours_Actual.RepDate)+1,
,1,0),DateSerial(Year(Tbl_Hours_Actual.RepDate),
Month(Tbl_Hours_Actual.RepDate)+1,1)) AS YTDHours

(this is untested, but you get the idea...)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:45 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.