I have the following code that gets all request where the Start Date and End Date fall in the current year. What I now need it to do is get all the request from 2012 or last years data.
( YEAR(StartDateAndTime) = YEAR(GETDATE())
OR YEAR(EndDateAndTime) = YEAR(GETDATE())
)
Microsoft DevelopmentMicrosoft SQL ServerMicrosoft SQL Server 2008
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
If you're looking for the code you need for the date ranges where StartDateAndTime & EndDateAndTime are the variables then try the following:
Select * from TABLE where StartDateAndTime > '2011-12-31 23:59:59' and EndDateAndTime < '2013-01-01 00:00:00'
Is this what you're talking about or are you looking for something dynamic?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
Select * from TABLE where StartDateAndTime > '2011-12-31 23:59:59' and EndDateAndTime < '2013-01-01 00:00:00'
Is this what you're talking about or are you looking for something dynamic?