07-25-2024 08:18 AM
How can I trim the date on the left hand side and convert this into a date value?
Input Example: 18 May 2016 - 17 Mar 2017
Output example: 2016-05-18
(using the yyyy-MM-dd format)
I've tried using trimLeft() function but the Mapper Snap doesn't recognise this expression (see screenshot attached).
Solved! Go to Solution.
07-26-2024 03:24 AM
Hello @NAl,
Could you try with the following expression, and let me know if it works for you?
Date.parse($Dates.split("-")[0].trim(),'dd MMM yyyy')
Regards,
Aleksandar.
07-25-2024 09:25 AM
Hello @NAl! A quick clarifying question, you want to take a string like "18 May 2016 - 17 Mar 2017", trim off the second date so you have "18 May 2016" then convert that to a date like "2016-05-18"? Or are you looking to convert both dates to the result would be "2016-05-18 - 2017-03-17"?
07-26-2024 12:54 AM
Hi @RogerSramkoski,
It'll be the first option so "2016-05-18"
07-26-2024 03:12 AM
So I have the expression which splits the date:
$Dates.split(' - ')[0]
which provides the result 18 May 2016.
But the expression below for reformatting the date results in a NaN ouput:
Date.parse($Dates.split(' - ')[0],"yyyy-mm-dd")
07-26-2024 03:24 AM
Hello @NAl,
Could you try with the following expression, and let me know if it works for you?
Date.parse($Dates.split("-")[0].trim(),'dd MMM yyyy')
Regards,
Aleksandar.