Basic Logics · Date Functions · Datetime functions · Real Scenario Logic's

Date in Our Language using SQL

Introduction

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

Follow Blog and Show your Support for many more interesting upcoming Posts!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

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