title: How can I add leading zeros to dates in Oracle?
body: <p>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.</p>
  
  <p><strong>My Attempt:</strong> </p>
  
  <pre><code>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;
  </code></pre>
  
  <p><strong>Result:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/mfxLM.png" alt="enter image description here"></p>
  
  <p>So, my problem is how can I remove the space in between month-year and month-day. I used</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>but the leading zeros disappear.</p>