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

del
Contributor III

One possible option:

[LocalDate.parse($.get('LINEAR_PREMR_DATE') || '01/01/4000'),LocalDate.parse($.get('GO_PREMR_DATE') || '01/01/4000'),LocalDate.parse($.get('VOD_PREMR_DATE') || '01/01/4000')].sort().shift()

You may need to reformat the output.

Rahulsingh
New Contributor

Date.parse(Date.parse(Math.min(($MAX_LINEAR_PREMR_DATE == null ? 64060588800000 : Date.parse($MAX_LINEAR_PREMR_DATE).getTime()),($MAX_GO_PREMR_DATE == null ? 64060588800000 : Date.parse($MAX_GO_PREMR_DATE).getTime()),($MAX_VOD_PREMR_DATE == null ? 64060588800000 : Date.parse($MAX_VOD_PREMR_DATE).getTime()))).toString()).toLocaleDateTimeString({“format”:“MM/dd/yyyy hh:mm:ss aa”})

I am having similar difficulties getting the syntax right after two months of trying. I know SQL and not Java so I am having some trouble with dates and logic expressions. Here are my date issues:

Date.parse($DATE_ELECTED).toLocaleDateTimeString({“timeZone”:“America/New_York”, “format”:“MM-dd-yyyy”})

Here is what i get with the DATE_ELECTED column is the given $DATE_ELECTED. The column called OUTSIDE DEADLINE is the one with the above logic. Why is it showing as a day earlier?

|DATE_ELECTED|OUTSIDE_DEADLINE|
|10/03/2022|10-02-2022|
|09/21/2022|09-20-2022|
|09/23/2022|09-22-2022|

@heidi.andrew

Using Date.parse() on a date-only value will set a datetime value to midnight UTC for that date (ex. 2022-10-03T00:00:00.000 UTC). By changing the time zone to New York time, you are effectively changing it to UTC-05:00 (or -04:00 for daylight saving time), so the date-only value will show one day earlier. If you need to keep the exact date value, then you can leave out the timeZone key/value entirely.

Date.parse($DATE_ELECTED).toLocaleDateTimeString({"format":"MM-dd-yyyy"})