Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
D19PAL
Creator II
Creator II

Two dates day duration withing -30 days and + 30 days.

Hi,

I have two date columns and I want an if flag statement to

 

Tell me the rows with duration withing -30 days or + 30 days..

So if date one and date 2  within 30 +\- days yes, if -31 or 31 or more then no.

 

Thanks

 

 

2 Replies
maxgro
MVP
MVP

You can try with the bold statement in the example below.

// Make some test data, 2 date columns, Date1 and Date2, with random dates of 2022 year
T:
LOAD
DATE(makedate(2022) + floor(rand()*365)) as Date1,
DATE(makedate(2022) + floor(rand()*365)) as Date2
AutoGenerate 100;

// Check if the difference between Date1 and Date2 is <= 30. You can use math, Date1 - Date2. 
T2:
LOAD
Date1, Date2,
Date1 - Date2 as Delta,
IF(FABS(Date1 - Date2) <= 30, 1, 0) as [Delta <=30]
Resident T;

DROP TABLE T;

 

 

maxgro_0-1643479024580.png

 

D19PAL
Creator II
Creator II
Author

Thanks 

I'll try it tomorrow.