Working with Hijri Date in SQL server

Saturday 12 September 2009

Here's an example to convert the Hijri Date to Gregorian date in SQL Server


1430/09/23 is today's Hijri date.Lets see how to convert this into Gregorian date


SELECT CONVERT(DATETIME, '23/09/1430', 131)


It would return 2009-09-12 00:00:00.000


The vice-versa,conversion from Gregorian date to Hijri date would be,


SELECT CONVERT(NCHAR, GETDATE(), 131).And this returns 23/09/1430  2:52:17:920PM







5 comments:

Fahad said...

What is Hijri Date?

The Trainer said...

Fahad, Hijri date follows the Islamic calender..You can find more about Hijri calender here : http://en.wikipedia.org/wiki/Hijri

Fahad said...

I know hijri calender but how come it shows hirji date when we convert date in character format?
What is logic behind it...???

The Trainer said...

SQL server BOL provides the syntax to convert the Hijri date to Gregorian date and vice-versa.I hope this link would give you more insight about the internals of Hijri calendar in Windows :Hijri Calender in Windows

Dear Magesh,

I tried using this method but seems not working.

I have hijri dates in one column and want to convert it into Gregorian if it is not in hijri.

Regards.