0

I have deserialize data date time, and save it in my database table column:

\/Date(1328029200000+0700)\/

But can I convert it to date format again using query sql?

4

1 に答える 1

0
declare @jsondate varchar(40) = '\/Date(1328029200000+0700)\/';
select substring(@jsondate,8,10) -- seconds
      ,substring(@jsondate,18,3) -- milliseconds
      ,substring(@jsondate,21,5) -- utc offset
      ,
-- this next expression is what you need
       cast(convert(char(20),
       dateadd(ms,1*substring(@jsondate,18,3),
       dateadd(ss,1*substring(@jsondate,8,10),'19700101'))
        ,120) + stuff(substring(@jsondate,21,5),4,0,':')
            as datetimeoffset(4));

-- result 2012-01-31 17:00:00.0000 +07:00
于 2012-10-04T12:19:36.130 に答える