A statement written at work
select * from Bt_Holiday whereto_char(Setting_DATE,'YYYY')=Substr('2015-03-00',1,4) AND to_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))
The statement means to obtain the month in the date.
The function of to_char() function is to convert numeric or date type into character type.
select to_char(sysdate,'YYYY') from dual 输出为:2015 select to_char(sysdate,'MM') from dual 输出为:08 select to_date('2001-12-01','yyyy-mm-dd') from dual 输出为:2001/12/01 select sysdate from dual 输出为:2015/8/17 20:14:34 Substr('原始字符串','第几个字符开始','截取几个字符') select Substr('2015-03-00',1,4) from dual 输出为:2015
Instr('Source string string1', 'String string2 to be found in string1', 'Starting from which character', 'Number of occurrences of string string2 to be found') Return The position of the string to be intercepted in the source string.
Recommended tutorial: "Oracle Tutorial"
The above is the detailed content of How to convert Oracle time to string. For more information, please follow other related articles on the PHP Chinese website!