Click here to Skip to main content
14,981,383 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a small application in C# for data's read from Excel and then store the datas to Sql Server 2008. In Excel there is a column for Hijri_Date like dd/MM/yyyy format,

Example: 17/4/1432

I need to read from Excel and update it to SQl Server 2008. For that in sql server what datatype has to declare for this? either DateTime or datetime2 ?

And what will be the update statement?

C#
Update MyTable set My_Hijri_Dt=?? where MyField1='MyValue';

Does anybody can give the details?

Thanks BY
PARAMU
Posted
Updated 9-Jun-19 23:34pm
v2

I'm not 100% certain about this, but according to this[^] SQL server only supports Greogrian Dates. This makes some sense as al-Hijri is one of the few calendars that doesn't follow the solar year and the difficulty where lunar observations are applied. You can change a UTC date to a Hijri on using the cast/convert[^] functions if you want, but it's probably better to store do everything on the SQL server side in UTC, and write a function to convert to al-Hijri on the client.
   
Comments
[no name] 18-Jun-19 8:22am
   
thanks!
Declare @Hdate nvarchar(50)
set @Hdate = convert(varchar(10),convert(date,convert(varchar(12),@thedate,131),103),112)
   
Comments
CHill60 10-Jun-19 5:21am
   
Msg 241, Level 16, State 1, Line 2
Conversion failed when converting date and/or time from character string.
almounkez 10-Jun-19 5:34am
   
Declare @Hdate nvarchar(50)
set @Hdate = convert(varchar(10),convert(date,convert(varchar(12),GETDATE(),131),103),112)
select @Hdate

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900