SQL SERVER – Display Dates in Different cultures FORMAT

Today we are going to learn a very simple and interesting concept which is used very little in the industry. It is about how to Display Dates in Different cultures FORMAT.

SQL SERVER - Display Dates in Different cultures FORMAT culturesFORMAT-800x250

Let us assume that you want to display your current date and time in different formats in different geographic locations with the help of SQL Server. In SQL Server we have an option for function FORMAT which can make things easy for us.

For example, if you want to convert today’s date and time to any other culture’s date and time, you can easily do that by using the following query.

DECLARE @dt DATETIME = GETDATE();
SELECT FORMAT( @dt, 'F', 'en-US' ) 'US English'
,FORMAT( @dt, 'F', 'gu') 'Gujarati India'
,FORMAT( @dt, 'F', 'es' ) 'Spanish'
,FORMAT( @dt, 'F', 'is') 'Icelandic'; 

The result of the query will be as following:

SQL SERVER - Display Dates in Different cultures FORMAT culturesFORMAT

 

Well, that’s it for today. You can use any other local and get your preferred results. I will be interesting to see what is your local and its result, why not paste that in the comment section below.

Here are my few recent videos and I would like to know what is your feedback about them. You can also subscribe to my YouTube Channel – SQL in Sixty Seconds.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

SQL DateTime, SQL Scripts, SQL Server
Previous Post
Slowloris DDoS Attack Mitigation
Next Post
SQL SERVER – Unlocking User Without Changing Password

Related Posts

5 Comments. Leave new

  • I got the error of

    Msg 195, Level 15, State 10, Line 2
    ‘FORMAT’ is not a recognized built-in function name.

    Reply
  • SQL Server 2012. You may need to revise the article to indicate which SQL Server version support the FORMAT function, thanks.

    Reply
  • Ooops sorry, my apology. I just tested the SQL Server version is 2008 R2..

    Reply

Leave a Reply