manipulation of date between two dates

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
satheesh_color
Participant
Posts: 182
Joined: Thu Jun 16, 2005 2:05 am

manipulation of date between two dates

Post by satheesh_color »

Hi All,

I have startdate and enddate as an incoming columns, based on which i would like to get everymonths between the given dates.

StartDate:10/18/2014
EndDate:03/22/2015

Expected output:
1-10-2014
1-11-2014
1-12-2014
1-01-2015
1-02-2015
1-03-2015

Kindly let me know your thoughts on the same.


Thanks,
Satheesh.R
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Re: manipulation of date between two dates

Post by thompsonp »

Do you have a database available? Which one?
satheesh_color
Participant
Posts: 182
Joined: Thu Jun 16, 2005 2:05 am

Post by satheesh_color »

Yes..we do have Oracle10g.



Thanks,
Satheesh.R
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

Code: Select all

SELECT SRC_TBL.StartDate,
    SRC_TBL.EndDate,
    ADD_MONTHS(TRUNC(SRC_TBL.StartDate,'MM'),RNO-1) MTH_STRT_DT
  FROM SRC_TBL
  LEFT OUTER JOIN
    (SELECT ROWNUM RNO FROM DUAL CONNECT BY LEVEL <= 240
    ) RW
  ON 1 = 1
  WHERE ADD_MONTHS(TRUNC(StartDate,'MM'),RNO-1) <= EndDate
You are the creator of your destiny - Swami Vivekananda
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Post by thompsonp »

or you could take a look at Oracle's Pipelined Table Functions
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or transformer looping if you have 8.5 or higher.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply