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
manipulation of date between two dates
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 182
- Joined: Thu Jun 16, 2005 2:05 am
Re: manipulation of date between two dates
Do you have a database available? Which one?
-
- Participant
- Posts: 182
- Joined: Thu Jun 16, 2005 2:05 am
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