Search code examples
sqlsql-serverdatetimesql-server-2012date-conversion

Change date month from Hijri to Gregorian


I have table in which I have two columns with name "Month" and "Year"

Here are there values "4" and "1438" respectively both column values are from Hijri calendar.

Now I want to change all values of month in table from Hijri to Gregorian.

I just tried to do so for one value in this way,

select convert(datetime, value, 131)
from (
    values ('01-04-1424  9:54:59:767AM')
    ) samples(value)  

It has successfully changed it to "2003-06-01 09:54:59.767"

But how can I change all values of month column from table my table name is "Employ"

Hope for your suggestions.


Solution

  • You have to replace column name instead of value

     SELECT CONVERT(DATETIME, concat('01-', month_column,'-', year_column), 131) FROM Employ