Removing time from a datetime field in SQL
I’ve got a small project at work that required me to use the date, but not the time in a datetime field for retrieval of certain rows from a table in SQL Server 2000. A bit of Googling revealed a document titled “Remove seconds from datetime SQL”. The title isn’t quite right, as the author’s query removes hours and minutes too, but the result turned out to be just what I wanted.
The query: SELECT Cast(Convert(varchar, GetDate(),105) as datetime) I ended up using code 101 instead of 105 to get my query working, but that was it.