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
 Transact-SQL (2000)
 Help Please Day Week query

Author  Topic 

0341
Starting Member

21 Posts

Posted - 2007-08-28 : 10:39:45
I am trying to write a query that returns the date of the previous monday regardless of what day of the week it's run on. Any help would be greatly appreciated.

Thanks,
Phil

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-28 : 10:52:51
[code]SELECT DATEADD(WEEK, DATEDIFF(WEEK, 0, CURRENT_TIMESTAMP), 0),
DATEADD(WEEK, DATEDIFF(WEEK, 7, CURRENT_TIMESTAMP), 0)[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

0341
Starting Member

21 Posts

Posted - 2007-08-28 : 10:59:23
Thank you Peso! That worked.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-28 : 11:03:35
Also see this VIEW
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=86769



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -