SQL Server function to convert Unix time to local datetime -


I convert a Unix time value to SQL Server for an efficient SQL Server function (in my case 2005) Viewing data time, using local time (especially taking account of summer adjustment - i.e. just not adding to 01/01/1970 in seconds)

  SELECT DATEADD (second, @ts, {d '1970-01-01'})  

After you date, now you do dateadd For the date of return you will need some functions to check the DST on the basis of DST state, Sample:

  build function [DBO]. [Fn_GetDaylightSavingsTimeStart] (@ year varchar (4)) DSTSTRteEa SmarterDate @DTSEndWeek smalldatetime set @DTSStartWeek = '03 / 01 / '+ Convert (varchar, @year) Return Date datepart (dw, @dtsstartweek) when date date date 1 (hour, 170, @ DTSTTATEAQ 2) then dateadd (hour, 314, @ dtststattek), when 3 days (hours, 290, dtststreet, one), after 4 minutes, dated date (hour, 266, dtststttehike), 5 minutes time (242 hours) , DTSTTATEAk), after 6 minutes, Dated (Hour, 218, DTSTST) when End date end of 7 days (hour, 194, dtststhrhh)  

You will need a simulier function to search DST after completion, take a look at this site for more information. :


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -