Wednesday, September 29, 2010

Formatting Dates in query output

In Oracle we'd use the to_char to nicely format a date in mm/dd/yyyy (or other) output. It's very nice because you can supply whatever date format you want, and it is easy to mix and match.

In SQL Server, you must memorize the date format you want. To format a date use this code for mm/dd/yyyy format:

select CONVERT(nvarchar,dob,101)

No comments:

Post a Comment