You are currently browsing the monthly archive for March 2010.

Quite often during data conversion processes, I am required to get only the date part from a datetime or a timestamp value. Here is a trick that does not involve CASTing and is quick to respond:

DATEADD(DAY, 0, DATEDIFF(DAY, 0, <ColumnName>))

Here is how it works: Whether smalldatetime or datetime, DATEDIFF(DAY, 0 returns the number of days since the base date, and DATEADD(DAY, 0 returns the integer as a date value.

Neat, isn’t it ?

Timeline

March 2010
M T W T F S S
« Jan   May »
1234567
891011121314
15161718192021
22232425262728
293031  

Blog Stats

  • 9,380 hits
Follow

Get every new post delivered to your Inbox.