加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

PostgreSQL字符日期和UNIX时间戳转换

发布时间:2020-12-13 17:25:58 所属栏目:百科 来源:网络整理
导读:一、日期格式转换 1.字符日期格式转化为UNIX时间戳格式 字段endtime为内容为UNIX时间戳格式,例如1346650755 select * fromtest where endtime = extract(epoch FROM date('2012-09-03 00:00:00')); 2.UNIX时间戳转化为字符日期格式 select * fromtest where

一、日期格式转换

1.字符日期格式转化为UNIX时间戳格式

字段endtime为内容为UNIX时间戳格式,例如1346650755

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

2.UNIX时间戳转化为字符日期格式

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


select uid,date(to_timestamp(insert_time)),count(*) from pubinfo where uid in (56,57,58,59,60) group by uid,date(to_timestamp(insert_time)) order by uid,date(to_timestamp(insert_time))

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读