码迷,mamicode.com
首页 > 数据库 > 详细

PostgreSQL时间戳提取的特殊需求

时间:2015-04-21 12:54:18      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:

基础函数及解析可参考:

http://blog.csdn.net/snn1410/article/details/7741283

PostgreSQL自带to_date(text, text)、to_timestamp(text, text);不存在to_time函数

 

需求:

08:30-20:30 → A

20:30-08:30 → B

 

脚本:

SELECTCASE WHEN (to_char(finished - time 08:30, HH24) > 11)
          THEN B
              ELSE A 
                 END
 )  bbCode
FROM
tablename

 

finished - time ‘08:30‘  (08:30即节点时间,逆时针方向倒转至0点,则0-12为A,12-24为B)

 

PostgreSQL时间戳提取的特殊需求

标签:

原文地址:http://www.cnblogs.com/vincentzee/p/4443868.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!