Someone please shed some light on how to write a select statement that will only pull out a bunch of records belongs only to a certain month. The field(sys_date) that keeps track of each record is a datatime field. Let's say that I need to select all the records starting from 03/01/2007 to 03/31/2007 at the end of March. I can't hardcode the dates because this report is scheduled to run at the end of every month via a DTS job in Sql 2000. Please help out. Thanks.
blumonde
Found the solution. Just in case anyone needs it:
Where (DATEPART(Month, sys_date) =
DATEPART(Month, GETDATE())) And (DATEPART(Year, sys_date) = DATEPART(Year,
GETDATE()))
Hope that helps.
No comments:
Post a Comment