Date in Our Language using SQL

Written by

In this blog post, we will see how we can use Dates in Some of our Local Languages!

Date in Our Language

We can achieve this by using FORMAT Function of SQL Server.

Syntax

FORMAT ( value, format , culture  )

SQL Script

DECLARE @Current_DateTime DATETIME;
SELECT @Current_DateTime=SYSDATETIMEOFFSET() AT TIME ZONE 'India Standard Time';  -- IST Format
--We can also Use other Time Zones here

SELECT
FORMAT(@Current_DateTime,'dddd, MMMM  d','en-us') 'English',
FORMAT(@Current_DateTime,'dddd, MMMM  d','ta-in') 'Tamil',
FORMAT(@Current_DateTime,'dddd, MMMM  d','hi-in') 'Hindi',
FORMAT(@Current_DateTime,'dddd, MMMM  d','te-in') 'Telugu',
FORMAT(@Current_DateTime,'dddd, MMMM  d','kn-in') 'Kannada';

Image Pic

Note

We can also use other Time Zones. On-Premises Supports Less number of Time Zones where as Azure Supports more.

To See Available Time Zones in our DB, Use below Query-

select * from sys.time_zone_info;

We can also use other culture info. Check here to know some of available Culture Info.

Conclusion

Thus we saw how to use Dates in Some of our Local Languages in SQL. All of the above mentioned scripts work in both On-Premises and Azure SQL Database. Unit tested as well.

Related Blog posts

Article Categories:
SQL Server

Leave a Reply

Your email address will not be published. Required fields are marked *

Shares