Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Simple example for converting string to datetime without getting a convert exception

Highlighted

Simple example for converting string to datetime without getting a convert exception

New Contributor

Hello,

it seems that my question is really simple when I read some blogs or some other posts but it is not clear to me how to convert a json string date to a datetime object for saving it to an ms sql database. Maybe somebody can explain it in a very simple way.

I get a object as json from a rest api. After this I try to convert this json with the convertJsonToSql processor and update the sql arg with my date to a date with the following expression: ${sql.args.n.value:toDate("yyyy-MM-dd HH:mm:ss")}

After this I give it to my putSql processor. When I execute this I receive an exception called "The value of the sql.args.n.value is '2017-12-07 14:10:49', which cannot be converted to a timestamp". My column in the database is a datetime type.

Thanks for your help!

Michael

Don't have an account?
Coming from Hortonworks? Activate your account here