Skip to main content
Solved

Convert character field to date/time in csv

  • February 3, 2023
  • 3 replies
  • 242 views

epro_admin
Contributor
Forum|alt.badge.img+7

Hi FME community,

I am still fairly new to FME. I'm getting stuck with date/time fields in csvs and excel documents. I've attached the field I'm trying to convert into DD/MM/YYYY HH:MM (%d/%m/%Y %h:%m ?), but it writes out empty if I try the DateConverter or AttributeManager> Text editor > DateTimeFormat. It's likely I'm using the transformers incorrectly. Is anyone able to point me in the right direction?

Best answer by j.botterill

Hi epro,

Firstly ensuring the CSV reader separatesimage the columns, confirming the delimiter type in the parameter's

 

So 15/08/2022 10:59:52 a.m. appears to be a custom "Input" format. Expanding the quick reference and using the Preview to see if we have the correct syntax and

image soon find that perhaps the a.m. and p.m. needs a stringreplacer before the Dateconverter?

imageanother string replacer for the pm...

run to the last string replacer and inspect the new date field valuesimageInput format

%d/%m/%Y %H:%M:%S %p

15/08/2022 10:59:52 am

 

 

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

j.botterill
Influencer
Forum|alt.badge.img+55
  • Influencer
  • Best Answer
  • February 3, 2023

Hi epro,

Firstly ensuring the CSV reader separatesimage the columns, confirming the delimiter type in the parameter's

 

So 15/08/2022 10:59:52 a.m. appears to be a custom "Input" format. Expanding the quick reference and using the Preview to see if we have the correct syntax and

image soon find that perhaps the a.m. and p.m. needs a stringreplacer before the Dateconverter?

imageanother string replacer for the pm...

run to the last string replacer and inspect the new date field valuesimageInput format

%d/%m/%Y %H:%M:%S %p

15/08/2022 10:59:52 am

 

 

 


Forum|alt.badge.img+2
  • February 3, 2023

@epro_admin​ Thanks for including a small sample dataset - that makes it much easier to test a solution.

Just for completeness... The CSV reader has the capability to parse data/time fields, it's buried in the reader parameters:

imageBut... in this case it won't help since there is no way around the 'a.m.' or 'p.m.' format, so you have to use the approach described by @jamesb16otterill​ 


epro_admin
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • February 7, 2023

Thank you both for your replies!