SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need to pull data since last November(year change)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jaimealvarez
Starting Member

31 Posts

Posted - 08/20/2014 :  15:50:25  Show Profile  Reply with Quote
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 be
tadate >= '11/1/2014'

and so on...

Thank you!

tkizer
Almighty SQL Goddess

USA
36983 Posts

Posted - 08/20/2014 :  15:56:59  Show Profile  Visit tkizer's Homepage  Reply with Quote
where tadate >= '11-01-' + convert(char(4), year(getdate())-1)

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/

Edited by - tkizer on 08/20/2014 15:57:15
Go to Top of Page

bitsmed
Constraint Violating Yak Guru

398 Posts

Posted - 08/20/2014 :  16:13:16  Show Profile  Reply with Quote
Shouldn't this be (see red)
quote:
Originally posted by tkizer

where tadate >= '11-01-' + convert(char(4), year(dateadd(mm,2,getdate()))-1)

Go to Top of Page

tkizer
Almighty SQL Goddess

USA
36983 Posts

Posted - 08/20/2014 :  16:26:15  Show Profile  Visit tkizer's Homepage  Reply with Quote
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 Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

jaimealvarez
Starting Member

31 Posts

Posted - 08/20/2014 :  16:55:43  Show Profile  Reply with Quote
Thank you both!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000