通过将hijri birthdate转换为Gregorian的值来更新birthdate的日期是Hijri

时间:2015-09-30 04:37:10

标签: sql gregorian-calendar hijri

表包含许多在BirthDate列中具有Hijri日期值和Gregorian值的记录,因此请如何通过将Hijri日期转换为Gregorian的值来更新Birthdate 谢谢 我尝试过这个脚本,但它不起作用 - 我的意思是没有变化 - 虽然我得到了

(18422行(s)受影响)

UPDATE MEMBER
SET BIRTHDATE = case when (SUBSTRING(cast(birthdate as nvarchar), 1, 2) ='14') 
or 
(SUBSTRING(cast(birthdate as nvarchar), 1, 2) ='13')
then 
(SELECT CONVERT(date, birthdate , 131) ) 
else
 birthdate
 end

1 个答案:

答案 0 :(得分:0)

尝试下面的代码,它会将birthdate列记录转换为Hijri格式:

更新会员 设置BIRTHDATE = CONVERT(VARCHAR(100),birthdate,131)--- [Hijri date to Gregorian date]

更新会员 设置BIRTHDATE = CONVERT(datetime,birthdate,131)--- [公历日期到Hijri日期]

有几篇关于此的博客,请注意:http://blogs.msdn.com/b/wael/archive/2007/04/29/sql-server-hijri-hijra-dates.aspx