Hi I have a column with number datatype the data like 1310112000 this is a date, but I don't know how to make it in an understandable format: ex: 10-mar-2013 12:00:00 pm
Can any one please help me.
If you need milliseconds, you need to add a further multiplication / division by 1000. For example, converting from epoch time (milliseconds) to a date would be "=((((A1/1000)/60)/60)/24)+DATE(1970,1,1)".
First, convert that 10 digit Unix Time in seconds to a DateTime. You can do that by dividing Unix Time by 86400. Then add Epoch Date Time and GMT to this DateTime. Again reminding you, if your timezone is GMT- , please do change the last part of the formula accordingly like -time(hr,min,sec) .
The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).
In Microsoft SQL Server, the previous answers did not work for me. But the following does work.
SELECT created_time AS created_time_raw,
dateadd( second, created_time, CAST( '1970-01-01' as datetime ) ) AS created_time_dt
FROM person
person
is a database table, and created_time
is an integer field whose value is a number of seconds since epoch.
There may be other ways to do the datetime
arithmetic. But this is the first thing that worked. I do not know if it is MSSQL specific.
That is EPOCH time: number of seconds since Epoch(1970-01-01). Use this:
SELECT CAST(DATE '1970-01-01' + ( 1 / 24 / 60 / 60 ) * '1310112003' AS TIMESTAMP) FROM DUAL;
Result:
08-JUL-11 08.00.03.000000000 AM
Please try
select from_unixtime(floor(EPOCH_TIMESTAMP/1000)) from table;
This will give the result like E.g: 2018-03-22 07:10:45 PFB refence from MYSQL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With