Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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;
Thanks
I'll try it tomorrow.