簡體   English   中英

如何在postgresql中將日期格式轉換為毫秒?

[英]How to convert date format into milliseconds in postgresql?

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

如何使用postgreql的select子句將其轉換為毫秒?

目前我只是執行select子句

select tableDate,tableSales 
from table_name

我希望有一些像我選擇tableDate的東西,它應該使用一些postgresql函數轉換為毫秒。

tableDate DATE
tableSales Numeric

extract(epoch from ...)將返回自1970-01-01 00:00:00以來的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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM