JavaScript - JSON 2 SQL - DateTime

JSON-2-SQL-DateTime

Topic, on examining a JSON input stream, Michelle found something like

1
<datebuilt>224121600000 </datebuilt>

In studying this a bit, it turns out 224121600000 is the number of milliseconds since the javascript
epoch date which is Jan 1, 1970 at midnight.

So to convert this into a SQL Server datetime field you would need to do something like

1
print DATEADD(s, cast('224121600000' as float)/1000, '1970-01-01 00:00:00')

which returns a value like

1
Feb  7 1977 12:00AM