Date to/from ID Conversion – TSQL

/*Convert DateTime to ID (yyyymmdd)*/
select replace(convert(char(10),getdate(),120),’-',”)

/*Convert DateID (yyyymmdd) to Date*/
SELECT CONVERT(DATETIME, CONVERT(CHAR(8), 20080922))

Tags: , , ,

Saturday, September 27th, 2008 SQL Server 2005

No comments yet.

Leave a comment

You must be logged in to post a comment.