โ01-21-2020 03:12 AM
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))
โ10-19-2022 11:00 AM
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?
โ10-19-2022 11:24 AM
@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)
โ10-19-2022 11:27 AM
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.
โ10-20-2022 04:58 AM
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โ}))
โ10-19-2022 11:04 AM
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!