如何在postgresql中将日期格式转换为毫秒?

时间:2016-03-08 07:00:08

标签: postgresql

我在postgresql中的日期格式为“17/12/2011”。

如何使用postgreql的select子句将其转换为毫秒?

目前我只是执行select子句

select tableDate,tableSales 
from table_name

我希望有一些像我选择tableDate的东西,它应该使用一些postgresql函数转换为毫秒。

tableDate DATE
tableSales Numeric

1 个答案:

答案 0 :(得分:3)

extract(epoch from ...)将返回自1970-01-01 00:00:00以来的秒数,因此您需要做的就是将其乘以1000:

select extract(epoch from tableDate) * 1000, tableSales 
from table_name

手册中的更多细节:

http://www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT

相关问题