Results 1 to 2 of 2

Thread: Date generator

  1. #1
    Join Date
    Apr 2013
    Posts
    19

    Unanswered: Date generator

    Hi,
    We have a table that has the following data

    Mcode Month
    009 201311
    027 201307
    026 201310

    I need to generate data for upto 36 months backwards from the month value for each Mcode

    e.g.

    Mcode Month
    009 201311
    009 201310
    009 201309
    .....
    009 201011
    027 201307
    027 201306
    .....

    Can someone please help me on this?

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    From today's date, that would be
    Code:
    select to_char(add_months(trunc(sysdate, 'mm'), -level + 1), 'yyyymm') result
    from dual
    connect by level <= 36;
    Adjust it so that it works with your data.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •