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)
 Date Calculations

Author  Topic 

blackX
Posting Yak Master

102 Posts

Posted - 2009-08-04 : 14:18:00
Hello, it has been a while since I have came to this site but I would like to thank everyone on this forum for their help. I need a query that will be the date of Sunday after 10 days from the current date. Example, if 8/4/2009 was the date in question, the date I need for this example would be 8/16/2009. I.E. The ten days from today would be 8/14/2009 and the following Sunday is the 16th. I know this is doable but I am having troubles.

Thanks in advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-04 : 15:05:50
[code]SELECT DATEADD(DAY, DATEDIFF(DAY, -17, GETDATE()) / 7 * 7, -1)[/code]


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

blackX
Posting Yak Master

102 Posts

Posted - 2009-08-04 : 20:03:50
quote:
Originally posted by Peso

SELECT	DATEADD(DAY, DATEDIFF(DAY, -17, GETDATE()) / 7 * 7, -1)



N 56°04'39.26"
E 12°55'05.63"




thanks that did the trick. Where would I modify it if I want Monday instead of Sunday?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-05 : 00:50:12
The "-1" part to "0".



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -