This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a conversion statement which converts Timestamp into Milliseconds in PostgreSQL Server.
There are multiple reasons where we need milliseconds from the given Timestamp like comparing the timestamp value in number format for exact matching.
We can use EPOCH time format, to get the milliseconds from Timestamp.
Get milliseconds without specifying timezone:
1 |
SELECT EXTRACT(EPOCH FROM (SELECT NOW())) * 1000; |
Get milliseconds by specifying timezone:
1 |
SELECT EXTRACT(EPOCH FROM (SELECT NOW() AT TIME ZONE 'UTC')) * 1000; |