oracle日期正则表达式


1900-2999日期正则表达式

  • YYYY-MM-DD
 select case
            when regexp_like('2999-11-30',
                             '^((((19|2\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((19|2\d)\d{2})-(0?[469]|11)-(0?[1-9]|[12]\d|30))|(((19|2\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|((19([02468][048]|13579)[26]|2\d(0[48]|[13579][26]|[2468][048])|(2000))-0?2-(0?[1-9]|[12]\d)))$') then
             1
            else
             0
          end
     from dual;

  • YYYY/MM/DD
 select case
            when regexp_like('2999/11/30',
                             '^((((19|2\d)\d{2})/(0?[13578]|1[02])/(0?[1-9]|[12]\d|3[01]))|(((19|2\d)\d{2})/(0?[469]|11)/(0?[1-9]|[12]\d|30))|(((19|2\d)\d{2})/0?2/(0?[1-9]|1\d|2[0-8]))|((19([02468][048]|13579)[26]|2\d(0[48]|[13579][26]|[2468][048])|(2000))/0?2/(0?[1-9]|[12]\d)))$') then
             1
            else
             0
          end
     from dual;
  • YYYY.MM.DD
select case
            when regexp_like('2012.02.29',
                             '^((((19|2\d)\d{2})\.(0?[13578]|1[02])\.(0?[1-9]|[12]\d|3[01]))|(((19|2\d)\d{2})\.(0?[469]|11)\.(0?[1-9]|[12]\d|30))|(((19|2\d)\d{2})\.0?2\.(0?[1-9]|1\d|2[0-8]))|((19([02468][048]|13579)[26]|2\d(0[48]|[13579][26]|[2468][048])|(2000))\.0?2\.(0?[1-9]|[12]\d)))$') then
             1
            else
             0
          end
     from dual;


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM