String to date conversion


(Kalicharan Khetwal) #1

Hello Team,

I’m struggling in conversion from string to date. How can we perform this within column assigner?

I tried with below expression but not working:

toDate(inpStringValue,‘MM-DD-YYYY’)
or toDate(inpStringValue)

Thanks
KC


(Jayant Singh) #2

Can you check the format of your string? the second argument of toDate() should be the format.


(Kalicharan Khetwal) #3

Hi Jayant,

String format is ‘MM/DD/YYYY’ and I have put the expression as:
toDate(inpStringvalue,‘MM/DD/YYYY’) but still getting error saying:
The expression result type DAY must be convertible to expected type STRING.

Thanks


(Victoria Tuktarova) #4

Hello Kalicharan,

Let me please clarify that you are receiving this error, because in the Column field the defined column has incorrect datatype.

The converted column will have DAY datatype, hence in Column field you need to define/create a column of this datatype. Please, see the screenshot.

Kind regards,
Victoria


(Kalicharan Khetwal) #5

Hi Victoria,

I tried using alter format component and it works well with the format you mentioned ‘MM/dd/yyyy’, however it didn’t work with column assigner transform. Anyway its working fine now. Thanks for your help.


(Victoria Tuktarova) #6

Hi Kalicharan,

I am very glad the issue is resolved now.

Kind regards,
Victoria