Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grouping Query on a date range 2

Status
Not open for further replies.

LDG1234

Programmer
Jun 26, 2001
120
0
0
GB
HI guys... i hope that you can help me out.

I have a mass of data which I need to analyse, specifically by lots of different criteria, but I need to calculate in blocks of months.

Does anyone know how to group on calender months??

Eg.

Date Volume
01/01/01 2
04/01/01 3
08/01/01 5
01/02/01 1
06/02/01 4
19/02/01 6

...to return

Month(or date range) Volume
01/01 10
02/01 11

Any ideas??

Many thanks






Lloyd Gozzett
Process Developer
 
Lloyd,

You need to use Format on the date....

Format(YourField,"mm/yy")

This can then be grouped and the other field counted/summed/whatevered.....

Hope that helps

Craig
 
select format([myTable]![myDate], "mm/yy") as mDate, sum([myTable]![myVolume]) as volume
from myTable
group by format([myTable]![myDate], "mm/yy")

or if you want to keep as a date/time column:

select dateserial(Year([myTable]![myDate]), Month([myTable]![myDate]), 1) as mDate, sum([myTable]![myVolume]) as volume
from myTable
group by dateserial(Year([myTable]![myDate]), Month([myTable]![myDate]), 1)

converts all dates to 1st of month Best Regards,
Mike
 
Thanks guys......thats really helpful Lloyd Gozzett
Process Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top