I need to add leading zeros to a number if it is less than two digits and combine two such numbers into single one without space between them.
My Attempt:
select ( extract (year from t.Dt)
|| to_char(extract (month from t.Dt),'09')
|| to_char(extract (day from t.Dt),'09') ) as dayid
from ATM_FACTS t;
Result:
So, my problem is how can I remove the space in between month-year and month-day. I used
select ( extract (year from t.Dt)
|| to_number(to_char(extract (month from t.Dt),'09'))
|| to_number(to_char(extract (day from t.Dt),'09')) ) as dayid
from ATM_FACTS t;
but the leading zeros disappear.