Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Is there a Week function in SQL ?

Author  Topic 

matkwan
Starting Member

36 Posts

Posted - 2002-07-22 : 12:15:56
Hi I have been using Month() function to generate report, eg,

SELECT Count(Quote_ID), Month(Quote_Date)
FROM tbl_Quotes
GROUP BY Month(Quote_Date);

But my boss wants the report to be grouped by Week, is it possible ?

By the way I am using Access 97

Thanks.
Matt


joldham
Wiseass Yak Posting Master

300 Posts

Posted - 2002-07-22 : 12:52:19
SELECT Count(Quote_ID), datepart("ww", Quote_Date), datepart("yyyy", Quote_Date)
FROM tbl_Quotes
GROUP BY datepart("ww", Quote_Date), datepart("yyyy", Quote_Date)

Again, I would suggest adding year to this so as not to confuse year-to-year data.

If you look at Format Property - date/time in the Access help, you will see the different things you can do with datepart.

This particular one returns the week of the year (1-52). You might have to put several functions in to get maybe the date of the first Monday of each week in the year.

Jeremy

Go to Top of Page

matkwan
Starting Member

36 Posts

Posted - 2002-07-22 : 13:45:56
Thanks Jeremy, you are the MAN :)

Go to Top of Page
   

- Advertisement -