Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
How to find Monthname between 2 dates StartDate and EndDate
Document | StartDate | EndDate | |
350003428 | 12/15/2010 | 12/14/2011 | |
350003429 | 8/1/2010 | 12/21/2010 | |
350003430 | 1/1/2009 | 4/21/2009 | |
Expecting Results | |||
Document | StartDate | EndDate | New Column |
350003428 | 12/15/2010 | 12/14/2011 | Dec2010,Jan2010,……. Dec2011 |
350003429 | 8/1/2010 | 12/21/2010 | Aug2010,Sep2010,Nov2010,Dec2010 |
I am looking for the result or value similar like New column
Advance thanks for your help.
Here you go:
M:
LOAD * INLINE [
Document, StartDate, EndDate
350003428, 12/15/2010, 12/14/2011
350003429, 8/1/2010, 12/21/2010
350003430, 1/1/2009, 4/21/2009
];
tmp:
LOAD Document,
monthstart(addmonths(StartDate, iterno()-1)) as Month
RESIDENT M
While monthstart(addmonths(StartDate, IterNo()-1)) <= EndDate;
LEFT Join (M)
LOAD Document,
Concat(monthname(Month), ', ') as AllMonths
RESIDENT tmp
Group By Document;
DROP Table tmp;
Here you go:
M:
LOAD * INLINE [
Document, StartDate, EndDate
350003428, 12/15/2010, 12/14/2011
350003429, 8/1/2010, 12/21/2010
350003430, 1/1/2009, 4/21/2009
];
tmp:
LOAD Document,
monthstart(addmonths(StartDate, iterno()-1)) as Month
RESIDENT M
While monthstart(addmonths(StartDate, IterNo()-1)) <= EndDate;
LEFT Join (M)
LOAD Document,
Concat(monthname(Month), ', ') as AllMonths
RESIDENT tmp
Group By Document;
DROP Table tmp;
Great Help.Thanks Rakesh.