I want to convert this: 2014-07-15 15:01:16.880
To: 2014-07-15
Or to: 2014-07-15 00:00:00:000
What is the best way to do this?
By the way, My database is inside a Microsoft SQL 2005 Server
Thanks in advance
I want to convert this: 2014-07-15 15:01:16.880
To: 2014-07-15
Or to: 2014-07-15 00:00:00:000
What is the best way to do this?
By the way, My database is inside a Microsoft SQL 2005 Server
Thanks in advance
There is no Date
datatype in SQL Server 2005, it was added in SQL Server 2008.
To go with your second alternative, you can truncate the datetime to midnight on the same day:
SELECT DATEADD(DAY, DATEDIFF(DAY,0, YourDateColumn), 0)
FROM YourTable
You could use CONVERT
to do the conversion.
SELECT CONVERT('2014-07-15 15:01:16.880', GETDATE(), 112)