Home  >  Article  >  Database  >  How to convert Oracle time to string

How to convert Oracle time to string

hzc
hzcOriginal
2020-06-08 14:28:033342browse

How to convert Oracle time to string

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn