Member since
08-29-2018
5
Posts
5
Kudos Received
1
Solution
My Accepted Solutions
Title | Views | Posted |
---|---|---|
14885 | 08-31-2018 07:13 AM |
06-17-2020
01:45 AM
Why do you have toNumber() in there, @skiganesh ?
... View more
08-31-2018
07:13 AM
2 Kudos
Per @Steven Matison's suggestion, I'm posting the solution to the problem I was facing as an answer: I was using the wrong processor. It turns out the UpdateRecord processor is a good fit for this. I'm updating the field in question with the following expression language command: ${field.value:toDate('MM-dd-yyyy HH:mm:ss'):format('yyyy-MM-dd HH:mm:ss')} Here's an XML template that demonstrates this functionality: updaterecord-datetime-conversion.xml
... View more
08-30-2018
06:30 AM
1 Kudo
Thanks! For the next person trying to accomplish something like this, I've attached another xml template that demonstrates this functionality: updaterecord-datetime-conversion.xml
... View more
08-29-2018
02:56 PM
2 Kudos
Hi, With NiFi, I'm picking up a CSV file whose records have a bit of a silly timestamp format: MM-dd-yyyy HH:mm:ss. I want to convert this into yyyy-MM-dd HH:mm:ss before attempting to insert this into a SQL server datetime field. To do this, I'm trying the ConvertRecord processor, with a CSVReader and currently a JSONRecordSetWriter (convenient since it allows me easily read the resulting data. An example CSV is: id;timestamp
1;11-12-2016 9:38:13
2;12-12-2016 9:38:14
3;12-21-2016 9:38:15
For the CSVReader, my schema text is: {
"type": "record",
"name": "testdata",
"fields": [
{
"name": "id",
"type": "int"
},
{
"name": "timestamp",
"type": {"type":"string","logicalType":"timestamp"}
}
]
}
I've set the property Timestamp format to MM-dd-yyyy HH:mm:ss. I'm using the same schema text for the JSONRecordSetWriter and have the Timestamp format set to yyyy--MM-dd HH:mm:ss. I'm expecting this to achieve the datetime conversion that I need to do, but in the resulting JSON my datetime field is exactly the same. Attached you'll find and XML template that demos this. Am I going about this the wrong way and completely misunderstanding what ConvertRecord does? Am I missing something?datetime-format-conversion.xml Edit: I'm still interested to hear your take on this, but as it so often goes I solved the problem a little while after I posted this question. I'm using UpdateRecord and doing: ${field.value:toDate('MM-dd-yyyy HH:mm:ss'):format('yyyy-MM-dd HH:mm:ss')} That works for me.
... View more
Labels:
- Labels:
-
Apache NiFi