Jump to content

Date Rule to return Graphic not working


Recommended Posts

Below is the rule that I am working with



if (FormatDate(Field("BIRTH_DATE"),"mm/dd/yyyy") > FormatDate("08/31/1963","mm/dd/yyyy"))


return Resource("Entertainment TL_Sept.jpg");




return Resource("Better with Age Day_new TL_Sept.jpg");




My problem is that I have the date of 10/08/1942 and it is returning the Entertainment graphic rather than the Better with Age Day and I have a 05/15/1976 that is doing the opposite. Other dates are working fine. Any idea what I am doing wrong?

Link to comment
Share on other sites

You're comparing strings rather than dates. You should convert them to actual dates:

var birthday = new Date(Field('BIRTH_DATE'));
var cutoff = new Date('08/31/1963');
var file = birthday > cutoff ? 'Entertainment' : 'Better with Age Day_new';
return Resource(file + ' TL_Sept.jpg');

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...