PostgreSQL时间戳提取的特殊需求

基础函数及解析可参考:

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)

 

posted @ 2015-04-21 11:12  Vincent Zee  阅读(719)  评论(0编辑  收藏  举报