How to convert Gregorian date to Hijri date SQL Server 2012

In this post, I will explain How to convert Gregorian date to Hijri date SQL Server 2012


Convert Gregorian date to Hijri date in SQL Server

SQL Server 2012 introduces a new Format function that used to achieve the same result.

SELECT FORMAT ( GETDATE(), 'dd/MM/yyyy', 'ar-SA' )

Output

16/08/1435

You can also use the below query

SELECT convert(nvarchar(10),GetDate(),131)

Output

16/08/1435 3:42:19:760PM
How to convert Gregorian date to Hijri date SQL Server 2012

Show Hijri date month name in SQL Server

If you need to show the month name you can replace 131 with 130

SELECT convert(nvarchar(15),GetDate(),130)

Output

16 شعبان 1435

Note: you should use “nvarchar” to show Arabic month name correctly.


Applies To

  • SQL Server 2012.
  • SQL Server 2014.
See Also
Have a Question?

If you have any related questions, please don’t hesitate to ask it at deBUG.to Community.

3 thoughts on “How to convert Gregorian date to Hijri date SQL Server 2012”

  1. I’m certainly happy to found out this blog please keep up ,and I’ll be bookmarking it and checking back often!

Leave a Reply

Scroll to Top