Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get yearstart from today - 3 years

Hi

I´m trying to rewrite a datefield. If the date are less then 2011-01-01 I want to set it to 2011-01-01. By I would like it to be dynamic so it check against yearstart 3 years back. (next year it should check against 2012-01-01...)

If(Datefield < YearStart 3 years back from today, rewrite to Yearstart 3 years back else use Datefield) as NewDatefield

My problem is how to write that.

Year(YearStart(Today()))-3) gives me 2011.

So I guess´d another Yearstart would fix it but it did´t work YearStart(Year(YearStart(Today()))-3)

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Try

yearstart(today(),-3)

View solution in original post

3 Replies
Anonymous
Not applicable
Author

Try

yearstart(today(),-3)

Gysbert_Wassenaar

yearstart will return a date, year(yearstart(....)) will return a year. If you want the first of januari 2011 returned you can use yearstart(today(), -3).


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

USE BELOW EXP:

year(AddYears(YearStart( today()),-3))