Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

InMonthsToDate() problems

I have a temp table that gets autofilled with dates (1/1/2009 - Today())

Iwould like to flag all dates that are within the previous 6 months.

Using InMonthsToDate() yields strange results.

InMonthsToDate(3,myDate, Today(),0) flags dates for the past 2 months

InMonthsToDate(4,myDate, Today(),0) flags dates for the past 3 months

I'm not sure why its not going back 3 and 4 months respetively....odd behavior

Similaraly



InMonthsToDate(6,myDate, Today(),0) flags dates for the past 5 months (7/1/2009 - 11/8/2009)

I can't put a 7 in the first parameter, it isn't allowed.

So how do I flag these dates?

Thanks

-Andy



1 Reply
Bill_Britt
Former Employee
Former Employee

You might try something like this.

inmonthtodate

(D, $(vToday), 0) * -1 AS CMTD, //Current month-to-date



inmonthtodate(D, $(vToday), -1) * -1 AS PMTD, //Previous month-to-date

inmonthtodate(D, $(vToday), -12) * -1 AS FPMTD, //First prior month-to-date, same month last year

inmonthtodate(D, $(vToday), -24) * -1 AS SPMTD

//Second prior month-to-date, same month two years ago



InMonths ( n, date, basedate , shift [, first_month_of_year = 1] )

Bill - Principal Technical Support Engineer at Qlik
To help users find verified answers, please don't forget to use the "Accept as Solution" button on any posts that helped you resolve your problem or question.