SQL Convert datetime to just a date

Categories:

Here is how to use the SQL convert function to extract just the date portion of a SQL datetime field.


convert(varchar(10), eventdate, 101)


It will result in something like this:


04/20/2010



You can change the syntax slightly if you want a different date format. Here is the full documentation on the convert function: http://msdn.microsoft.com/en-us/library/aa226054%28SQL.80%29.aspx