12-05-2018 12:32 PM
Hi everyone,
I’ve been trying to convert data I’m receiving from a varchar (20171211 125023) into a datetime (2017-12-11 12:50:23). I’ve been messing with the mapper but I feel like I’m at a road block now. I was wondering if someone in the community has any success in this.
12-05-2018 08:39 PM
Hi Matt
You can use Date.parse() function to convert input string to Datetime.
Date.parse(“20170604 125452”, “yyyyMMdd HHmmss”)
this will give desired output.
convertVarcharToDate_2018_12_06.slp (2.6 KB)
12-06-2018 05:54 AM
Hi Matt,
You can try with the below expression in your mapper. Hope this helps
Date.parse(“20170617 125254”,“yyyyMMdd hhmmss”).toLocaleDateTimeString({“format”:“yyyy-MM-dd hh:mm:ss”})
The output value will be
12-06-2018 06:16 AM
Hey Pavan,
Thank you for the reply, I just have a quick question. If I have a input scheme for example $DATE that’s bringing in data, would I just replace “20170617 125254” with the schema?
12-06-2018 06:19 AM
Yes, That’s correct.