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