Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
i have data like
Load * inline [
Startdate,Enddate
'26-jan-2015 12:45:20','14-Mar-2012 11:36:24'
];
My requirement is
1.i want to data from Startdate,Enddate like 26-jan-2015,14-Mar-2012
2.Difference between (26-jan-2015-14-Mar-2012) Months
Hi Sharath,
Please use the following script
Test:
Load
Date(Date#(Startdate,'dd-MMM-yyyy hh:mm:ss'),'dd-MMM-yyyy') As Startdate,
Date(Date#(Enddate,'dd-MMM-yyyy hh:mm:ss'),'dd-MMM-yyyy') As Enddate,
Interval(Date(Date#(Enddate,'dd-MMM-yyyy hh:mm:ss'),'dd-MMM-yyyy')-Date(Date#(Startdate,'dd-MMM-yyyy hh:mm:ss'),'dd-MMM-yyyy'),'d') As Months ;
Load * inline [
Startdate,Enddate
'26-jan-2015 12:45:20','14-Mar-2015 11:36:24'
'27-jan-2015 12:45:20','17-Mar-2015 11:36:24'
];
Regards,
Faisal M A
Thanks Faisal for your quickly replay.
Hi,
Try like this
SET MonthDiff = Num(((year($2) * 12) + month($2)) - (((year($1) * 12) + month($1))) + 1);
Test:
Load
*,
($(MonthDiff(StartDate, EndDate)) AS MonthsDifference;
Load
Date(Date#(Startdate,'dd-MMM-yyyy hh:mm:ss'),'dd-MMM-yyyy') As Startdate,
Date(Date#(Enddate,'dd-MMM-yyyy hh:mm:ss'),'dd-MMM-yyyy') As Enddate
inline [
Startdate,Enddate
'26-jan-2015 12:45:20','14-Mar-2015 11:36:24'
'27-jan-2015 12:45:20','17-Mar-2015 11:36:24'
];
Hope this helps you.
Regards,
Jagan.