cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Date format problem

amit_saroha
New Contributor III

Hi,

I have a CSV file containing the dates like โ€˜16-DEC-2019โ€™ and I am reading the CSV file and inserting it into an Oracle database table but it always errors out because the format desired is a date in format yyyy/mm/dd hh:mi:ss.

I have used the below expression but it returns NULL as well. Can you please help me how to get it corrected?

Date.parse($[โ€˜Date Fromโ€™]!= null ? $[โ€˜Date Fromโ€™].toString().substr(0,10) : $[โ€˜Date Fromโ€™]).toLocaleDateString({โ€œformatโ€:โ€œyyyy/MM/dd HH:mm:ssโ€})

3 REPLIES 3

darshthakkar
Valued Contributor

@amit.saroha: Are you expecting the format yyyy/MM/dd HH:mm:ss for Null values?

no, they can be null.

Thereโ€™s probably a number of ways to write this out, but try this expression:

$['Date From'] != "" ? Date.parse($['Date From'],'dd-MMM-yyyy').toLocaleDateString({"format":"yyyy/MM/dd HH:mm:ss"}) : null

It may still need to be tweaked for your use case.