title: How to read a date value in YYYYMM format using substring in oracle
body: <p>In my table customer_records there is a column StartDate having value in <code>DDMMYYYYHHMMSS</code> format (column datatype is VARCHAR).<br>
  I want to extract the data from the table group by the date in <code>YYYYMM</code> format.</p>
  
  <p>I have below working query: which will extract the data in <code>MMYYYY</code> format.</p>
  
  <pre><code>SELECT /*+ PARALLEL(a , 8 ) */
            NVL (SUBSTR (StartDate, 3, 6), 'Total') "Year-Month",Started",
           TO_CHAR (COUNT (1), '999,999,999') "Customer Count",
           TO_CHAR (
                SUM (Usage)/60,
              '999,999,999')`enter code here`
              "Duration (M)"
      FROM customer_records a
     WHERE type='NEW'
            and customer_status=0 
  GROUP BY ROLLUP (to_date(SUBSTR (StartDate, 3, 6),'MMYYYY'), 'Total')
  ORDER BY 1;
  </code></pre>
  
  <p>but I want the Date format to come in <code>YYYYMM</code> format.<br>
  I have tried the following options. but not working,</p>
  
  <pre><code>SELECT /*+ PARALLEL(a , 8 ) */
          NVL (to_date(SUBSTR (StartDate, 3, 6),'MMYYYY'), 'Total') "Month Started",
           TO_CHAR (COUNT (1), '999,999,999') "Customer Count",
           TO_CHAR (
                SUM (Usage)/60,
              '999,999,999')
              "Duration (M)"
      FROM customer_records a
     WHERE type='NEW'
            and customer_status=0 
  GROUP BY ROLLUP (to_date(SUBSTR (StartDate, 3, 6),'MMYYYY'), 'Total')
  ORDER BY 1;
  </code></pre>
  
  <p>can somebody please help me to edit above query to fetch the data in <code>YYYYMM</code> format?</p>