cancel
Showing results for 
Search instead for 
Did you mean: 

Expression in mapper

Rahulsingh
New Contributor

how to write below expression in snaplogic

least(
IIF(ISNULL(LINEAR_PREMR_DATE),to_Date(‘01/01/4000’,‘mm/dd/yyyy’),LINEAR_PREMR_DATE),
IIF(ISNULL(GO_PREMR_DATE),to_Date(‘01/01/4000’,‘mm/dd/yyyy’),GO_PREMR_DATE),
IIF(ISNULL(VOD_PREMR_DATE),to_Date(‘01/01/4000’,‘mm/dd/yyyy’),VOD_PREMR_DATE))

9 REPLIES 9

That worked to bring in the correct date and format. On the next field, I need to add 31 days to the $DATE_ELECTED. If that date is <= today, it should be “true” --if not then false.

This syntax worked except the code does not that local date string and if the date occurred today, it would be true. I have tried a couple of things but cannot get the syntax just right to reflect that issue. Here is what was almost working perfectly before:

Date.parse($DATE_ELECTED).plusDays(31)<=Date.now()

Can you help it to recognize the local date so that the $DATE_ELECTED field is correct?

@heidi.andrew
Regarding your date time follow-up question:
There may be a dozen ways to reformat the syntax to achieve what you want, but this is the first thought to come to my mind (if I’m following your requirements right), which may not be the most optimized syntax option:

Date.parse($DATE_ELECTED).plusDays(31) <= Date.parse(Date.now().toLocaleDateTimeString({"timeZone":"America/New_York"}))

(obviously, if I misunderstood the requirement, this will not be helpful)

del
Contributor III

Regarding your second question around Match/Contains, I believe @bojanvelevski just now answered that question for you at How to use "contains" function in router? I am getting error of expression failure - #9 by bojanvele... while I was responding to your datetime question.

This worked perfectly. Thanks for your help.

adds 31 days to current date
Date.parse($DATE_ELECTED).plusDays(31).toLocaleDateTimeString({“format”:“MM-dd-yyyy”})

logic for date math:
Date.parse($DATE_ELECTED).plusDays(31) <= Date.parse(Date.now().toLocaleDateTimeString({“timeZone”:“America/New_York”}))

heidi_andrew
Contributor

I am also struggling to get logic to work like this:

$field1 in (“800”,“900”)
$field1 not in (“800”,“900”)

I have tried several things like using the || as “or” but really just need to make a list of items to include or exclude. Tried both MATCH and CONTAINS expressions. I have also been unable to add a target schema to my mappers. Still a beginner…maybe it just takes time to figure it out. The documentation seems to go towards Java and I am a sql person. Can I print out the documentation for a snap? I am bending your ear and I appreciate the help!