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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 DatePart SQL query.

Author  Topic 

abarsami
Yak Posting Veteran

68 Posts

Posted - 2001-02-03 : 02:58:18
I am trying to use datepart to accomplish some tasks.
I wrote a query that counts the number of messages in a message table. Now I want to take that result and display it based on some situations.

1) Weekly - if this is picked, it displays the number of messages on monday, tuesday, ... through Sunday
2) Monthly - displays # of messages on week1, week2, week3
3) Yearly - displays # of messages in Jan, Feb... and so on.

Is there a value in sql that knows what Monday is... For example does Monday = 1. Can I count the # of Mondays that a message has been written, if I know the date.

I know the top 3 choices will be in the where clause, but I would appreciate some help.
Thanks
   

- Advertisement -