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!