How to convert date time into unix epoch value in

2019-02-08 00:23发布

How do I convert the following format to UNIX timestamps?

A value like: 01-02-2015 10:20 PM should be converted to: 1418273999000

I did try to_timestamp function but its not working for me.

2条回答
SAY GOODBYE
2楼-- · 2019-02-08 00:39

If your data is stored in a column called ts, in a table called data, do this:

select extract(epoch from ts) from data
查看更多
Ridiculous、
3楼-- · 2019-02-08 01:04

To add Joe's answer, you can use date_part, i think it's syntax is clearer than 'extract'.

select date_part('epoch', ts) from data;

查看更多
登录 后发表回答