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.
Author |
Topic |
HenryFulmer
Posting Yak Master
110 Posts |
Posted - 2012-06-08 : 11:37:39
|
How can I calculate the date of September 30th of the previous year?I have a query by which I return sales records and I would like to always retrieve all records that date back until September 30th of the year before. |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-08 : 11:40:14
|
dateadd (yy,-1,convert(varchar(4),getdate(),112)+'0901'))==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-08 : 12:10:59
|
quote: Originally posted by HenryFulmer How can I calculate the date of September 30th of the previous year?I have a query by which I return sales records and I would like to always retrieve all records that date back until September 30th of the year before.
DATEADD(yy,DATEDIFF(yy,0,GETDATE()),'19000930')------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-06-08 : 12:36:02
|
One more way for fun: SELECT DATEADD(YEAR,YEAR(SYSDATETIME()) - 1901, '19000930') |
 |
|
|
|
|