工作中編寫過的一條語句
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))
語句的意思是取得日期中的月。
to_char()函數功能,就是將數值型或者日期型轉化為字符型。
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(‘源字符串string1′,’要在string1中查找的字符串string2′,’從第幾個字符開始’,’要查找第幾次出現字符串string2′)返回要截取的字符串在源字符串中的位置。
推薦教程: 《Oracle教程》
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END
喜歡就支持一下吧
相關推薦