Converting Dates in SQL Server

 

In the world of Application and DB Development there is always a need to display dates in a format that is understandable to your audience.  For example, in the US we normally expect to see a date as mm/dd/yyyy; however, in Great Britain, the normal format is dd/mm/yyyy.  The Convert function in SQL Server provides a means to translate SQL Server’s default date format to just about any format.

The syntax for the Convert function is as follows:

CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

Available Date Formats –

 Source Code

tsql

It shows some of the different ways dates can be formatted and produces the result below.

 

Below are a few resources that I found on using the Convert function.

I also posted a while back about Handling Dates in SQL Server.

Happy Learning!

Posted on January 18, 2009, in SQL Server. Bookmark the permalink. 1 Comment.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.