sql - How to get timestamp as timestamp from postgres? -
I want to get data from postgraduate. There is a column in the type timestamp without the timezone, the simple selection gives me a formatted date, but I just want a timestamp in milliseconds, how can I do it in SQL?
Select (era from my_timestamp)
This gives time in seconds though, it After decimals of decimal number is the decimal number with decimal number.
Remove (era from my_timestamp) * 1000
Test:
select my_date, remove (era from my_date) * Timelapse 'GMT'
Note on precision
at interval '1s' + 'epoch' :: time zone
returns a "double exact" number, which fits in 15 digits in postgres. This means that around 2016 (as I write), the actual accuracy is 10 microsounds. Note how it closes the final digit:
Remove selection ('2016-09-20T11: 22: 33.456789Z': 'era' from the timestamp); Date_part ------------------ 1474370553.45679 (1 line)
For the dates of the future of 270 years, this data type is only 100- Microsoft seems like a decent precision from 2016's perspective of being able to represent precision, and I think some things may change before reaching that year.
Remove Selection ('2290-09-20T11: 22': 33.456789Z ':: Timestamp from' Era '); Date_part ------------------ 10120 9 36953.4568 (1 line)
By any means, it is fine for milliseconds Will continue to work for some time accurate.
Comments
Post a Comment