Posts Tagged ‘datetime’

Keeping only the date part in a datetime field inside MS SQL query

Monday, April 14th, 2008

Since I had to google this to find a good way to only use the datepart of a datetime field from my database, I tought you might use this:

convert(datetime,(convert(varchar (11),getDate())))

The source is on http://www.bennadel.com/blog/122-Getting-Only-the-Date-Part-of-a-Date-Time-Stamp-in-SQL-Server.htm, where you can find other smart ways to do it. I found this was the easyest for me.