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
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
- Format date with AM PM and without second in SQL Server 2012.
- Get the Detailed Information Via SERVERPROPERTY.
- Get the first record added per day group by the user in SQL.
- Get the last record added per day group by the user in SQL.
- SQL Server: How to get the current installed update level.
Have a Question?
If you have any related questions, please don’t hesitate to ask it at deBUG.to Community.
is there a way to do the same conversion in Power Bi Desktop
I’m certainly happy to found out this blog please keep up ,and I’ll be bookmarking it and checking back often!
Thanks