October 16, 2007

Get the datetime representing the first day of a date

This is pretty useful when you need to get data from the past n months:

SELECT CAST(((convert(varchar(7),getdate(),121))+'-01') AS datetime)

No comments: