toDateTime giving a null value

Dear colleagues,
We are using the todateTime function to convert a string to Datetime format.
But we are getting a NULL output as answer.

toDateTime(BH_ID,'dd-MMM-yyyy HH:MM:SS')

Here, BH_ID is a string with value 30-Jul-2019 00:00:00. please let me know if there is sth wrong with syntax. Help/example is greatly appreciated.

thanks

Hi Jayant,

The problem comes from the format of the string which you use for the input format.

The correct syntax is: hours - HH , minutes – mm and for seconds - ss.

In your case, you have defined it as HH:MM:SS. Hence, if you change the format of the string to HH:mm:ss it should works.

Example for the given date format should be “dd-MMM-yyyy HH:mm:ss”:

toDateTime (BH_ID,“dd-MMM-yyyy HH:mm:ss”)

Regards,
Mario