04-14-2021 01:42 PM
I have an incoming file that has a date value of 00:00.00.000 as a value. I am trying to set it to null. Comparing the exit_date ==‘00:00:00.000’ fails. Checking Date.parse($exit_date)==’ ’ or Date.parse($exit_date==null fails. Date.parse($exit_date).ToLocalDateString() fails. Not sure how I can parse this data. Any ideas on how to map this value to null?
Solved! Go to Solution.
04-14-2021 05:45 PM
Try this expression in your mapper:
isNaN(Date.parse($.get('exit_date') || '')) ? null : Date.parse($exit_date).toLocaleDateTimeString()
Having not seen your entire input set, I can’t guarantee it will work for every record, but I think it will come very close, if not fully succeed.
The idea of this expression is:
If $exit_date exists and is translatable to dateobject, it will produce a datetime in which the LocaleDateTimeString() will result into a valid value; otherwise the result is null.
It is dependent on the expectation that NaN
is always the result from Date.parse() for non-parsable parameters.
04-14-2021 05:55 PM
Thank you. That worked.
04-15-2021 02:03 AM
Hi @SnapWizard,
As I see this is just a time not the whole date. And when you work only with time you should use LocalTime.parse()
instead of Date.parse()
.