Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Hi All,

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

3 Replies
Not applicable
Author

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

Not applicable
Author

Thanks Faisal for your quickly replay.

jagan
Luminary Alumni
Luminary Alumni

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.