SQL Server date function with st, th, nd and rd

SQL Server (and Reporting Services) give you a number of ways to format dates – bar the ones you actually want.. :p

There isn’t, for example, a way to pull out a standard date format that you would use in a letter – i.e. 29th November 2010. Instead you’d have to make to with 29 November 2010.

SO! Here is a magical function that will cure this horrendous lack of ordinal suffixes and return a tidy formatted date that we are not ashamed of putting on our reports.

Hurrah!

Example:

One thought on “SQL Server date function with st, th, nd and rd

Leave a Reply

Your email address will not be published.