Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
sersal10
Creator
Creator

how to create a boolean if a date is 2 years before

Hi all,

I have a field named sold_date and want to create another that is a boolean. 1 if sold_date is 2 years ago from today. The sold date format is MM/DD/YYYY in the sheet of Qlik.

I tried this but the new field is always 0.

if(Date#("sold_date", 'MM/DD/YYYY') = Date(MonthStart(Today(), -24)), 1, 0) as last_10d_2y,

 

Just in case, the script I have at the beginning of the load editor is this one:

SET ThousandSep=',';
SET DecimalSep='.';
SET MoneyThousandSep=',';
SET MoneyDecimalSep='.';
SET MoneyFormat='$ ###0.00;-$ ###0.00';
SET TimeFormat='h:mm:ss TT';
SET DateFormat='M/D/YYYY';
SET TimestampFormat='M/D/YYYY h:mm:ss[.fff] TT';
SET FirstWeekDay=6;
SET BrokenWeeks=1;
SET ReferenceDay=0;
SET FirstMonthOfYear=1;
SET CollationLocale='en-US';
SET CreateSearchIndexOnReload=1;
SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';
SET LongMonthNames='January;February;March;April;May;June;July;August;September;October;November;December';
SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';
SET LongDayNames='Monday;Tuesday;Wednesday;Thursday;Friday;Saturday;Sunday';
SET NumericalAbbreviation='3:k;6:M;9:G;12:T;15:P;18:E;21:Z;24:Y;-3:m;-6:μ;-9:n;-12:p;-15:f;-18:a;-21:z;-24:y';

MANY THANKS!!

Labels (3)
1 Solution

Accepted Solutions
maxgro
MVP
MVP

try

in script:  AddYears(today(2), -2) = sold_date as flag

or in a chart with sold_date: AddYears(today(2), -2) = sold_date

 

View solution in original post

2 Replies
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

 

If you try :

 

if(Date#("sold_date", 'MM/DD/YYYY')*1 = Floor(MonthStart(Today(), -24)), 1, 0) as last_10d_2y

 

Aurélien

Help users find answers! Don't forget to mark a solution that worked for you!
maxgro
MVP
MVP

try

in script:  AddYears(today(2), -2) = sold_date as flag

or in a chart with sold_date: AddYears(today(2), -2) = sold_date