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

How to get date 10 years older to the current date

Hello All,

Struggling with an issue which i thought would be rather simple.

I would need to do an bring up some data from SQL based on dates and the difference btwn them should be exactly 10 years.

Ex: If any user opens the app today they should be able to see date ranging from 2/18/2006 to 2/18/2016.

TIA!!

2 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

Use Addyears function.

Addyears(Date,-10)

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
sunny_talwar

May be set a variable like this:

MaxDate:

LOAD Date(AddYears(Max(Date), 10), 'DD-MMM-YYYY') as MaxDate,

          Date(Max(Date), 'DD-MMM-YYYY') as MinDate

Resident YourFactTable;

LET vMaxDate = Peek('MaxDate);

LET vMinDate = Peel('MinDate');


DROP Table MaxDate;

SQL

SELECT *

FROM Table

Where DateField >= $(vMinDate) and DateField <= $(vMaxDate);