天天看點

PostgreSQL字元日期和UNIX時間戳轉換

一、日期格式轉換

1.字元日期格式轉化為UNIX時間戳格式

字段endtime為内容為UNIX時間戳格式,例如1346650755

select * from test where endtime >= extract(epoch FROM date('2012-09-03 00:00:00'));

2.UNIX時間戳轉化為字元日期格式

select * from test where date(to_timestamp(endtime))>='2012-09-02';

本文轉自 pgmia 51CTO部落格,原文連結:http://blog.51cto.com/heyiyi/986612