How to write the code in Oracle SQL (like 'CCYYMMDD' into 102 )

前端 未结 3 1427
不知归路
不知归路 2021-01-28 10:12

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

3条回答
  •  被撕碎了的回忆
    2021-01-28 10:53

    If you want to convert an Oracle date into a Julian date, then you can use the TO_CHAR function with 'j' as the format.

    SELECT TO_CHAR(TO_DATE('BC47120412', 'BCYYYYMMDD'), 'J')
      FROM DUAL;
    
    Output: 0000102
    

    If you want to convert julian date to oracle date then use query below,

    SELECT TO_DATE(102, 'J') 
      FROM DUAL;
    
    Output: 04/12/4712 12:00:00 AM BC
    

提交回复
热议问题