Q: 當時日期時間是用integer型態儲存timestamp, 如何使用SQL指令直接將timestamp轉為date型態顯示?

A: 先使用to_timestamp函數將interger轉成timestamp, 後面再加上::date即可轉成"yyyy-mm-dd"格式。

ex:

SELECT to_timestamp(start_time)::date FROM abc;

--

參考自 http://stackoverflow.com/questions/16609722/postgres-how-to-convert-from-unix-epoch-to-date

http://stackoverflow.com/questions/6133107/extract-date-yyyy-mm-dd-from-a-timestamp-in-postgresql

--

 

arrow
arrow
    全站熱搜

    dizzy03 發表在 痞客邦 留言(0) 人氣()