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
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
gets you december onlyCode:select * from jobs where datepart(m,logdate)=12
gets you January and December.Code:select * from jobs where datepart(m,logdate)=12 or datepart(m,logdate)=1
Getting "not January and not December" is just a case of negating that -
although because we "know" something about months you can simplify it to:Code:select * from jobs where not(datepart(m,logdate)=12) and not(datepart(m,logdate)=1)
Code:select * from jobs where datepart(m,logdate) between 2 and 12
There are currently 1 users browsing this thread. (0 members and 1 guests)