Q:

Oracle converting date to number causes it to become 7 digits long instead of 8

I am currently converting a date to number using Oracle query. However for certain dates such as 08122019, it is becoming as 8122019
How can i tweak my query to show 0 in the beginning:
TO_NUMBER(TO_CHAR(MyDate, 'DDMMYYYY'))

A:

Here it is (though I have no idea why you would want the 3rd one, if what you're asking for is the first):
    SQL> select to_char(sysdate,'ddmmyyyy')  from dual;

    TO_CHAR(
    --------
    08122019

    SQL> select to_number(to_char(sysdate,'ddmmyyyy')) from dual;

    TO_NUMBER(TO_CHAR(SYSDATE,'DDMMYYYY'))
    --------------------------------------
                                   8122019

    SQL> select to_char(to_number(to_char(sysdate,'ddmmyyyy')),'09999999') from dual;

    TO_CHAR(T
    ---------
     08122019

