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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Rick_T
Contributor III
Contributor III

Date variable -1 year

Hello, 

I want to make a date variable which stores another date variable -1 year. 

The first date variable is a flexible one which the end users can fill in by them self. Then i want to make another variable which stores the date that the end user fills in -1 year. 

So for example: the end user fills in 29-8-2019. The new variable needs to take that date -1 year which will result in 29-8-2018. Does anyone have an idea how I can achieve this? 

 

Sincerely, 

Rick 

1 Solution

Accepted Solutions
dplr-rn
Partner - Master III
Partner - Master III

change this to

Aanmaakdatum = {"<=$(=Date(AddYears(Date#(vInput,'DD-M-YYYY'),-1),'DD-M-YYYY'))"}

View solution in original post

7 Replies
dplr-rn
Partner - Master III
Partner - Master III

Try below expression vInput is the variable for input

 

=Date(AddYears(Date#(vInput,'DD-M-YYYY'),-1),'DD-M-YYYY')

neelamsaroha157
Specialist II
Specialist II

You can call the existing variable and use AddYears.

For example you have a variable vVar1 which takes the input date from the user then you can create a second variable as vVar2 = AddYears(vVar1, -1).

Rick_T
Contributor III
Contributor III
Author

Hello, thanks for the reply. I am using the second variable as a filter within a set expression. 

It should look something like this 

sum(

{$<
Status -={'Canceled'},
Aanmaakdatum = {"<=$(vDateInput-1)"}
>}

[Kontr-afspr])

Where the vDateInput-1 is based on the original vDateInput. 

Rick_T
Contributor III
Contributor III
Author

Don't understand the calling a existing variable by addyears. I am trying this but it shows the original variable as a field not a variable. See below: 

clipboard_image_0.png

dplr-rn
Partner - Master III
Partner - Master III

change this to

Aanmaakdatum = {"<=$(=Date(AddYears(Date#(vInput,'DD-M-YYYY'),-1),'DD-M-YYYY'))"}

Rick_T
Contributor III
Contributor III
Author

Thank you sir, works like a charm! 🙂 

dplr-rn
Partner - Master III
Partner - Master III

No Problem