问题
I have simple table on my sql server
and in my table have a date field,and into date field save a hijri date
,i want use the sql server
convert function to convert hijri date
to gregorian date
.
how can i do this?
i use this query in sql server:
update k
set time=CONVERT(datetime,GETDATE(),101)
and i insert this "1392/4/21"
in time field ,and when convert sql server return this "2014/11/5"
,when i use online date convertor,and insert this "2014/11/5"
,convert date is "1393/2/14"
!!is this the correct resualt?
回答1:
Here is a sample how you could do it:
select convert(datetime, value, 131)
from (
values ('13/01/1436 9:54:59:767AM')
) samples(value)
There are several blogs about this, likethis one: http://blogs.msdn.com/b/wael/archive/2007/04/29/sql-server-hijri-hijra-dates.aspx
and this one: http://raresql.wordpress.com/2013/05/08/sql-server-how-to-convert-gregorian-dates-to-hijri-date-with-formatting/
来源:https://stackoverflow.com/questions/26749403/use-sql-server-convert-function-to-convert-hijri-to-gregorian-date