Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ashis
Creator III
Creator III

Comparing two month fields

Hi ,

I have mydate column which return date as 2019-07-08 (YYYY-MM-DD) format, e.g 8th of Jul 2019.

I am trying to compare this field with now () function in a text object. Here is the syntax.

=IF(DATE(TRIM(MAX(mydate )),'MMM')=date(TRIM(NOW()),'MMM'),1,0)

so it would compare Jul=Jul , if this is true then return 1 or 0.

The above syntax is returning 0, please advise how should i approach. 

1 Solution

Accepted Solutions
lblumenfeld
Partner Ambassador
Partner Ambassador

The issue is that Qlik isn't really representing the MMM format as expected when you do the comparison in the "if".

So, either

=IF(Text(DATE(TRIM(MAX(MyDate )),'MMM'))=Text(date(TRIM(NOW()),'MMM')),1,0)

or

IF(Month(MAX(MyDate ))=Month(NOW()),1,0)

will work.

The second statement is simpler.

Hope this helps.

View solution in original post

2 Replies
lblumenfeld
Partner Ambassador
Partner Ambassador

The issue is that Qlik isn't really representing the MMM format as expected when you do the comparison in the "if".

So, either

=IF(Text(DATE(TRIM(MAX(MyDate )),'MMM'))=Text(date(TRIM(NOW()),'MMM')),1,0)

or

IF(Month(MAX(MyDate ))=Month(NOW()),1,0)

will work.

The second statement is simpler.

Hope this helps.

ashis
Creator III
Creator III
Author

Thank you for your reply. Yes you are right