How can i convert numeric value to datetime?

494 views Asked by At

i have a sql database

table name    :   TB_EVENT_LOG
columns name :   ndatetime,nuserid

column ndatetime has anumeric values like

1433923965,1433865660,1433841912,....

i want to convert all values in ndatetime column to date and time values

and preview that in datagridview

2

There are 2 answers

1
Captain Coder On

The example values you provided can be interpreted as seconds since 1970-01-01 00:00:00 UTC (the unix epoch). It depends on your programming environment how you would convert these values to presentable formats. Usually it involves the creation of Date(/Time) objects with the right constructor, or formatting with a right format string.

0
Liu On

Looks like the numbers are total seconds since 1970-01-01. Check if the following SQL conversion is what you are looking for.

convert(datetime, dateadd(seconds, dateTimeInSeconds, '1970-01-01'))