当前位置:首页 > 数据库 > SQL其他

db2数据库date和timestamp日期转换to_char()函数

原文链接:https://blog.csdn.net/weixin_42076211/article/details/81092848

1、date()函数、time()函数、timestamp()函数

select date(trim(char('2009-09-01 '))),time(trim(char('12:23:34 '))),timestamp(trim(char('2009-02-26-14.28.40.234000')))
from sysibm.dual

db2数据库date和timestamp日期转换to_char()函数 - 文章图片

2、char()函数

select char(current date),char(current time),char(current timestamp) from sysibm.dual

db2数据库date和timestamp日期转换to_char()函数 - 文章图片

3、to_char()函数

select to_char(current timestamp,'yyyy-mm-dd hh24:mi:ss') from sysibm.dual

db2数据库date和timestamp日期转换to_char()函数 - 文章图片

范例三:将timestamp类型转换字符串类型,运用to_char函数

EBB925字段是timestamp类型

select * from ori_mv_ebb39 where to_char(EBB925, 'yyyy-mm-dd hh24:mi:ss') >= '2019-09-01 00:00:00'

TO_CHAR是转化函数

YYYY-MM-DD HH24:MI:SS 是格式

4、to_date()函数

select?to_date('2009-01-01?12:23:45','yyyy-mm-dd?hh24:mi:ss')?from?sysibm.dual

db2数据库date和timestamp日期转换to_char()函数 - 文章图片


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!