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 |
jaimealvarez
Starting Member
31 Posts |
Posted - 2014-08-20 : 15:50:25
|
Hi I have to pull data for a report from 11/1/2013 to date. But once we get to 11/1/2014 then the report should pull data from 11/1/2014 to date and so on. Is there a way to do this? I guess I could go in and change the year manually but was hoping that there was a way to do this autmoatically.so today would be tadate >= '11/1/2013'but at any point between 11/1/2014 to 10/31/2015 it should betadate >= '11/1/2014'and so on...Thank you! |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-08-20 : 15:56:59
|
where tadate >= '11-01-' + convert(char(4), year(getdate())-1)Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
bitsmed
Aged Yak Warrior
545 Posts |
Posted - 2014-08-20 : 16:13:16
|
Shouldn't this be (see red)quote: Originally posted by tkizer where tadate >= '11-01-' + convert(char(4), year(dateadd(mm,2,getdate()))-1)
|
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-08-20 : 16:26:15
|
quote: Originally posted by bitsmed Shouldn't this be (see red)quote: Originally posted by tkizer where tadate >= '11-01-' + convert(char(4), year(dateadd(mm,2,getdate()))-1)
Yep. I forgot about the November/December issue.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
jaimealvarez
Starting Member
31 Posts |
Posted - 2014-08-20 : 16:55:43
|
Thank you both! |
|
|
|
|
|