Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
burgersurfer
Contributor III
Contributor III

Problem using date in If statement

Hi

I am trying to use the following if statement:

If(CalendarMonthAndYear < 'Nov-2009', 'Use sub-cat', 'use FOP').

The CalendarMonthandYear range is developed using the MasterCalendar approach.

When selecting dates in any format (a list box for testing purposes) I get incorrect results - e.g. if I select May-2010, the result is 'Use sub-cat', where it should be 'use FOP'.

Similar errors when selecting other dates.

What is the correct syntax to correctly select all dates before Nov-2009 for a specific action, and everything from Nov-2009 onward for another?

1 Solution

Accepted Solutions
Not applicable

Hi there,

the issue with your code is that you compare against a string. May-2010 is 'smaller' than Nov-2009 because the letter M comes before N in the alphabet. You should really compare dates against dates.

So you should convert calendarMonthandYear to a date and then compare against a date, eg

date(Field, format) < '01.11.2009' [or whatever your default date format is]

Regards, Lukas

View solution in original post

2 Replies
Not applicable

Hi there,

the issue with your code is that you compare against a string. May-2010 is 'smaller' than Nov-2009 because the letter M comes before N in the alphabet. You should really compare dates against dates.

So you should convert calendarMonthandYear to a date and then compare against a date, eg

date(Field, format) < '01.11.2009' [or whatever your default date format is]

Regards, Lukas

burgersurfer
Contributor III
Contributor III
Author

Thanks Lucas, the string was exactly my problem