我在 postgresql 中有日期格式为“17/12/2011”。
如何使用 postgreql 的 select 子句将其转换为毫秒?
目前我只是执行 select 子句作为
select tableDate,tableSales
from table_name
Run Code Online (Sandbox Code Playgroud)
我想要一些类似的东西,当我选择 tableDate 时,它应该使用一些 postgresql 函数转换为毫秒。
tableDate DATE
tableSales Numeric
Run Code Online (Sandbox Code Playgroud)
a_h*_*ame 12
extract(epoch from ...)
将返回秒数,1970-01-01 00:00:00
因此您需要做的就是将其乘以 1000:
select extract(epoch from tableDate) * 1000, tableSales
from table_name
Run Code Online (Sandbox Code Playgroud)
手册中的更多详细信息:
http://www.postgresql.org/docs/current/static/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT