Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Convert date to ISO format

avatar
New Contributor

I am currently using nifi to transfer my data from RDS to DocDB. Now to put data into DocDB i am not using PutMongo, but using Python code. Now there are certain date fields from RDS which are in int format that must be stored in MongoDB in ISO date format. I tried converting it to date in my JSON Schema, but that stored date fields as YYYY-MM-DD as a string i.e even though those fields were in correct format, the corresponding data type was string and not date. Now ideally i can directly typecast my datatype to date in my Python code that pushes values to docDB, but please note that i need a solution for it in NiFi. Essentially, my flow has EXecuteMYSQLRecord(where i tried my JsonSchema as date), followed by JOLT to transform data into required hierarchy to be stored in docDB, followed by python code to insert into DocDB. Kindly help with a solution for converting date to ISO format in NiFi.

1 REPLY 1

avatar
Super Guru

@Nidutt you should be able to use NifI expression language in the flow to change date int to ISO timestamps. 

 

Here is a template you can use that shows many examples of timestamp formatting:

 

https://github.com/steven-matison/NiFi-Templates/blob/master/Working_with_TimeStamps.xml

 

I think you may find that nifi attributes remain strings in your flow without a strict date type, after all an ISO timestamp is really a string, your end point database just knows it is a "timestamp"....  

 

 

If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  

 

Thanks,


Steven @ DFHZ