Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Most recent 8 months date function

Hi

I have a date field [Start Date], and I want to load only records with start date in the  most recent 8 months, including current month. For example, for any date in November, I need to load records from Apr. 1st till Nov. 30th. I'm using this expression

"where [Start Date]>=AddMonths (monthend(today()), - 8);" in load script, but I got Mar. 31st loaded. Any idea why?

Thanks

Yvonne

1 Solution

Accepted Solutions
vishsaggi
Champion III
Champion III

Or try this?

Where [Start Date] >= MonthStart(AddMonths(MonthEnd(Today()), -7))

Here when you do MonthEnd of today you get 11/30/2017 and you are going back 8 months so it is going 30 Apr 2017. As Apr has 31 days when you do >= it pick up 31st too. So try the above expr and see.

View solution in original post

5 Replies
vishsaggi
Champion III
Champion III

May be try like

WHERE  [Start Date] > AddMonths (monthend(today()), - 😎

Anonymous
Not applicable
Author

Still has Mar. 31...without "="

vishsaggi
Champion III
Champion III

Or try this?

Where [Start Date] >= MonthStart(AddMonths(MonthEnd(Today()), -7))

Here when you do MonthEnd of today you get 11/30/2017 and you are going back 8 months so it is going 30 Apr 2017. As Apr has 31 days when you do >= it pick up 31st too. So try the above expr and see.

vishsaggi
Champion III
Champion III

I just checked yes do not use that expr. Try the one which i posted just now.

Anonymous
Not applicable
Author

Seems to work now. Thanks!