PostgreSQL 字符串处理与日期处理操作( 二 )


1.to_timestamp:
1AND to_timestamp(a.upload_time,’yyyy-MM-dd’)>='”+startTime+”‘ and to_timestamp(a.upload_time,’yyyy-MM-dd’) <= ‘”+endTime+”‘
2.substring:
1substring(‘2019-04-08 14:18:09’,index,k):
数值代表含义 index:代表从index开始截取数据 , k代表从index开始截取到第k个数据
处理对象:时间为字符串格式的数据
eg:
截取时间到 年-月-日:
1SELECT substring(upload_time,1,10) from table WHERE upload_time=’2019-04-08 14:18:09′
结果:2019-04-08
截取时间到 时:分:
1SELECT substring(upload_time,12,5) from table WHERE upload_time=’2019-04-08 14:18:09′
结果:14:18
文章来源:脚本之家
来源地址:https://www.jb51.net/article/205167.htm
【PostgreSQL 字符串处理与日期处理操作】申请创业报道 , 分享创业好点子 。 , 共同探讨创业新机遇!