您的位置 首页 技术

oracle时间怎么转字符串

工作中编写过的一条语句 select * from Bt_Holiday whereto_char(Setting_DATE,'YYYY')=Substr(&#…

工作中编写过的一条语句

select * from Bt_Holiday whereto_char(Setting_DATE,'YYYY')=Substr('2015-03-00',1,4) ANDto_char(Setting_DATE,'MM')=Substr('2015-03-00',6, (instr('2015-03-00','-',1,2))-(instr('2015-03-00','-',1)+1))
Substr('2015-03-00',6, (instr('2015-03-00','-',1,2))-(instr('2015-03-00','-',1)+1))

语句的意思是取得日期中的月。

to_char()函数功能,就是将数值型或者日期型转化为字符型。

select to_char(sysdate,'YYYY') from dual         输出为:2015select to_char(sysdate,'MM') from dual         输出为:08select to_date('2001-12-01','yyyy-mm-dd') from dual 输出为:2001/12/01select sysdate from dual      输出为:2015/8/17 20:14:34Substr('原始字符串','第几个字符开始','截取几个字符') select Substr('2015-03-00',1,4)  from dual   输出为:2015

Instr('源字符串string1','要在string1中查找的字符串string2','从第几个字符开始','要查找第几次出现字符串string2')返回要截取的字符串在源字符串中的位置。

推荐教程: 《Oracle教程》

以上就是oracle时间怎么转字符串的详细内容,更多请关注24课堂在线网其它相关文章!

本文来自网络,不代表24小时课堂在线立场,转载请注明出处:https://www.24ketang.cn/71137.html

为您推荐

返回顶部