Shrimpersfan Posted January 29, 2009 Posted January 29, 2009 Hi all. I am trying to use the DATEPART function on GETDATE() in the WHERE clause. I need to only show the results if GETDATE's month is not in December or January. Any ideas? Cheers
srochford Posted January 29, 2009 Posted January 29, 2009 select * from jobs where datepart(m,logdate)=12 gets you december only select * from jobs where datepart(m,logdate)=12 or datepart(m,logdate)=1 gets you January and December. Getting "not January and not December" is just a case of negating that - select * from jobs where not(datepart(m,logdate)=12) and not(datepart(m,logdate)=1) although because we "know" something about months you can simplify it to: select * from jobs where datepart(m,logdate) between 2 and 12
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now