How to write the code in Oracle SQL (like \'CCYYMMDD\' into 102 )?
If someone will enter the date in the frontend, the value should return
You cannot write a function to determine which numeric date string corresponds to which format as the date string could be multiple formats:
For example, 010203 could be:
DDMMYY 1st February 03MMDDYY 2nd January 03YYMMDD 3rd February 01DDHHMM 02:03 of Day 1HHMMSS 01:02:03MMMMSS 102 minutes 3 secondsCCYYMM March 0102CCYYWW Week 3 of 0102Similarly 10080102 could be:
DDMMCCYY 10th August 102CCYYMMDD 2nd January 1008MMDDHHMM 8th October 01:02HHMMHHMM Time span from 10:08 to 01:01If anyone inserts the date in this format "CCYYMMDD" then the value should return only 102 as a default in the frontend. How to write the code in SQL?
You cannot, as I described above it is ambiguous what some values are and they could return multiple formats. Instead you should create another column and store the date format in that when the user inputs the date rather than trying to reconstruct the format code from an (ambiguous) number.