Forum Discussion
3 Replies
- MinovskiNew Contributor II
Hi Shirali,
I have converted “Jun 17, 2019 12:00 AM” into “06/17/2019” .
This is solved in two ways in the Pipeline attached (ConvertDate_2019_09_30):- Solution with match expression, combined with slice() and replaceAll():
(match $date.slice(0,4){"Jan "=>“01/”,"Feb "=>“02/”,“Mar”=>“03/”,"Apr "=>“04/”,“May”=>“05/”,"Jun "=>“06/”,"Jul "=>“07/”,"Aug "=>“08/”,"Sep "=>“09/”,"Oct "=>“10/”,"Noe "=>“11/”,“Dec “=>“12/”,} + $date.slice(4,12).replaceAll(”, “,”/”))
- Solution with combining multiple expressions ( startsWith(), .replaceAll(), slice() )
PFA pipeline!
ConvertDate_2019_09_30.slp (8.3 KB)
Regards,
Nikola Minovski- ShiraliNew Contributor
Thank you! This worked.
Shirali
- tstackFormer Employee
You can specify the format to be used for parsing by passing it as the second argument to
Date.parse(). ThetoLocaleDateTimeString()method can also take an optional parameter where you can specify the format to use when turning the date into a string:Date.parse("Jun 17, 2019 12:00 AM", "MMM dd, yyyy hh:mm a") .toLocaleDateTimeString({format: "MM/dd/YYYY"})