Home > Net >  How to split and check the numerical date format (YYYYMMDD) in oracle database?
How to split and check the numerical date format (YYYYMMDD) in oracle database?

Time:06-13

I have a col which stores the date, but it is in a numerical format in 8 digits (e.g. 20220613) how can I split it and check with the condition?

  1. for the first 4 digits, I need to valid is it earlier than current year,
  2. for the middle 2 digits, I need to valid is it between 01 - 12,
  3. for the last 2 digits, I need base on the month to valid is it between 01 - 31 (e.g. if the the middle 2 digits (month) is 06, the last 2 digits can not greater than 31)

May I know that how to write this logic in oracle sql query? Thanks.

  • Related