Wednesday, 22 August 2018

Setup locale date time zone


SQL server saves date in local region format, for example if you’re in india and hosting your site with godaddy and choose Asia server then your date will be 12 hour forward compare to current region.
So if you want match the data as indian locale date use the following code while inserting date in server.



CONVERT(datetime,SWITCHOFFSET(CONVERT(datetimeoffset,GetUTCDate()),'+05:30'))