Question

Transfor Date String from 'YYYY-MM-DD' to Date String 'DD/MM/YYYY'

  • 21 April 2023
  • 5 replies
  • 16 views

Userlevel 2
Badge +10

HI All,

 

Any workaround to convert a date string (YYYY-MM-DD format) to DD/MM/YYYY ? The field type needs to stay as date string see below:

 

image 

I've tried a few transformers (StringReplacer + ListExploder+ String Concatenator) but couldn't get it to work and show 21/04/2023

 

Thanks


5 replies

Badge +4

Hi @galigis​ ,

 

Have you already tried the DateTimeConverter with the following settings?

image

Userlevel 2
Badge +10

Thanks @connecter​ - Yes, I have but fme gives me a rejection code 'INVALID_INPUT', see below:

 

image

Userlevel 5
Badge +29

Thanks @connecter​ - Yes, I have but fme gives me a rejection code 'INVALID_INPUT', see below:

 

image

Before you pass the features into the DateTimeConverter, what does fme show the value to be? I'm wondering if ArcGIS is doing some conversion when showing the date

Userlevel 2
Badge +10

Before you pass the features into the DateTimeConverter, what does fme show the value to be? I'm wondering if ArcGIS is doing some conversion when showing the date

Hi @hkingsbury​ - FME shows the Model_Date as 'YYYY-MM-DD' as string and ArcGIS is also treating the fields as string.

 

Over the weekend I came up with the solution, maybe isn't the most elegant workaround ever....but does the job :),

 

Here are the transformers used:

 

1- StringReplacer to replace '-' to '/'

2- AttributeSplitter to split filed by '/'

3- ListExploder

4-Sorter to sort the list values

5- (3) Testers to filter the element_indexes (day (2), month (1), year (0))

6- AttributeCreator to create 'Day', 'Month', 'Year' fields.

7- Feature Merger to join Day & Month by OBJECTID.

8- Feature Merger to join Month & Year by OBJECTID.

9- StringConcatenator to concatenate day, month, year

10- AttributeKeeper to keep the most important fields.

 

image 

image 

Any better workaround, please let me know! 🙂

 

Thanks

Userlevel 5
Badge +29

Before you pass the features into the DateTimeConverter, what does fme show the value to be? I'm wondering if ArcGIS is doing some conversion when showing the date

Based on the above, you should be able to use the solution provided by @connecter​ .

 

Can you provide a sample of the data?

Reply