Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
anuradhaa
Partner - Creator II
Partner - Creator II

Compare dates inside if satement

Hi,

I have data and i need to apply different values based on date.

I have the date format as '2014-06-07 17:02' i have used

Dual(Month(DATE_TIME) & '-' & Date(DATE_TIME, 'YY'), Num(Year(DATE_TIME)) & Num(Month(DATE_TIME), '00')) AS MonthYear,

to get monthyear.

then i need to apply one value till 'MAY-14' and another value after 'MAY-14'

i have used

=if((MonthYear < 'May-14' ), 'true' , 'yyy')

then for if Monthyear = 'JUNE-14 ' it display 'true' and may it show 'yyy'.

This is wrong. because 'JUNE-14' > May-14

please help me to solve this problem

4 Replies
Gysbert_Wassenaar

You're comparing strings. A word starting with a J is considered smaller than a word starting with an M. You need to compare numeric values instead. You can do that by creating dates from your strings.

=if((date#(MonthYear,'MMM-YY') < date#('May-14','MMM-YY'), 'true' , 'yyy')


talk is cheap, supply exceeds demand
anuradhaa
Partner - Creator II
Partner - Creator II
Author

It doesn't work , pls see attached qvw

ashfaq_haseeb
Champion III
Champion III

Hi,

look at the attached application.

Regards

ASHFAQ

MayilVahanan

HI

Try like this

=if(Date#(MonthYear,'MMM-YY') > date#('May-14','MMM-YY'), 'true' , 'yyy')

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.