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

How do I pull data from a rolling 18 months in the Script?

I would like to pull in 18 full months of data on a rolling basis. I do not want any partial months except for the current month. How would I accomplish this?

I experimented with the following let statements with no luck

LET vStartDate = (TODAY-547);
LET v18MonthsAgo = DATE(Month(vStartDate)-01-year(vStartDate));

***

Load  DATE("DATE_CHANGED", 'MM/DD/YYYY') as DateChanged;

FROM MyTable

WHERE "DATE_CHANGED" > '$(v18MonthsAgo)'

6 Replies
sunny_talwar

May be this

LET vStartDate = Num(MonthStart(Today(), -18));

Load  DATE("DATE_CHANGED", 'MM/DD/YYYY') as DateChanged;

FROM MyTable

WHERE "DATE_CHANGED" > '$(vStartDate)'

Anonymous
Not applicable
Author

I get error message "Conversion failed when converting date and/or time from character string"

sunny_talwar

Can you share a screenshot of the error message

Anonymous
Not applicable
Author

sunny_talwar

Try this

LET vStartDate = Date(MonthStart(Today(), -18), 'DDMMMYYYY');

Load  DATE("DATE_CHANGED", 'MM/DD/YYYY') as DateChanged;

FROM MyTable

WHERE "DATE_CHANGED" > '$(vStartDate)'

Anonymous
Not applicable
Author

As far as I can tell, this worked! Thank you for your help and quick responses!