Convert String date format in Jalali to Gregorian

All we need is an easy explanation of the problem, so here it is.

Hello I have The data table in oracle SQL 12c with 2 col one is thetime , and another is theh the data stored in cols are varchar and format like this :

THETIME | THEH
14000207| 1245
14000207| 1230
14000207| 1215
...

which the 14000207 tell is 1400(yyyy) , 02(MM) and 07(dd) and in THEH 12(HH) and 45(mm) I need to convert it to date format with time for better selecting the data but it’s a jalali date and Before do that I need converting to Gregorian , so how Can I do that?
ps :

the 1400-02-07 equal to 2021-04-27

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Try this one:

ALTER SESSION SET NLS_CALENDAR = 'Persian';

SELECT TO_DATE(THETIME || THEH, 'YYYYMMDDHH24MI')
FROM dual;

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply