Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
jmonroe918
Creator II
Creator II

Calculate Age (Days) Between 2 Dates

I have two dates: CreateDate and CloseDate and would like to calculate the age of the record that contains these two dates. My questions are:

  1. What is the expression for calculating the date difference to determine the age of each record?
  2. How do I incorporate that into the load code?


Thanks.

Jeff

11 Replies
Anonymous
Not applicable

Hi Jeffrey,

Use below load script:

Let vStartDate = MM/DD/YYYY;

Let vEndDate = MM/DD/YYYY;

Data:

LOAD

StartDate,

EndDate,

($(DateDiff(StartDate>$ (vStartDate) , EndDate <=$(vEndDate))) AS AGE

FROM DataSource;

Sokkorn
Master
Master

Hi Jeff,

May we can try this:

[TableName]:

Load *,

     If(DayOpen<30,'<30',If(DayOpen<61,'31-60',If(DayOpen<121,'91-121',If(DayOpen>120,'>120')))) as [OpenBucket];

Load

     ID,

     Status,

     CreateDate,

     CloseDate,

     Floor(Today()-CreateDate)     as DayOpen;

Select ID, Status, CreateDate, CloseDate From TableName;

Regards,

Sokkorn