June 22, 2007 at 9:33 pm
I would like to know how to transform any given date to day 1 of the year in the given date AND the new date must maintain the datetime/smalldatetime data type.
For example, if a user gives a date of 2006-06-23, I want to convert it to 2006-01-01.
June 22, 2007 at 9:38 pm
Substitute your date column or date variable for GETDATE() in the following...
SELECT DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)
--Jeff Moden
Change is inevitable... Change for the better is not.
June 22, 2007 at 9:42 pm
You the man Jeff!!!!!!!!!!!!!
June 22, 2007 at 9:43 pm
Heh... thanks for the feedback, David.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply