Gregorian Date to Hijri Date

Recently I was asked to help convert Gregorian Date to Hijri Date and vice versa.

One thing to note is that with Hijri date format you must keep it as a string.

SELECT CONVERT(varchar(30), GETDATE(), 131)
-- Returns: 30/01/1435  8:33:10:030AM
SELECT CONVERT(datetime, '30/01/1435  8:32:19:467AM', 131)
-- Returns: 2013-12-03 08:32:19.467
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.