Solved

Charvar to Date format


imageI have CSV file in the character format with a value as shown here. I would like to change it into Date format so I will be able to date calculation later. I tried to use Dateformater. it did not work. is there any other transformer that I can leverage to accomplish this?

icon

Best answer by ebygomm 9 May 2023, 08:29

View original

10 replies

Userlevel 5
Badge +25

Which parameters did you use in the DateFormatter?

Which parameters did you use in the DateFormatter?

Hello Redgeographics Thank you for your time.

 

Since my existing date is month day and year in string format, I used default to let FME or ISO to find the input parameter. Also I did not find m%d%y% format in the dropdown list. the output format I used default and %Y%m%d. The transfer ran successfully but the outcome filed was still sting in Sep 2, 2022. No changed literally. A little doubt about the datetime attribute, there was cor_date field and also @value(cor_date). I tried both. not sure of the difference between them.

imageAlternatively, I created the separate Date field and copy all information from occ_date to date field. The date field was no value.

Userlevel 5
Badge +25

The thing with the DateTimeConverter is that if the format you have (or want) is not in the dropdown list you can add the format string yourself. So "Sep 2, 2022" is %b %e, %Y (3-letter month 1- or 2-digit day, 4-digit year

Hi, I changed input and output format as %b %e, %Y, but the workbench ran successfully. The field also changed to Date format, but the values were null. All dates values were not carried over.

Userlevel 1
Badge +21

The input format in your screenshot and your sample csv file are different, can you confirm which is correct?

 

So for your screenshot it would be

%b %e, %Y

But for your csv example file the input format would be

%e-%b-%y2099

 

 

The input format in your screenshot and your sample csv file are different, can you confirm which is correct?

 

So for your screenshot it would be

%b %e, %Y

But for your csv example file the input format would be

%e-%b-%y2099

 

 

I just wonder should I have Date field before using dateformatter transformer? I want to change varchar to Date.

Userlevel 1
Badge +21

I just wonder should I have Date field before using dateformatter transformer? I want to change varchar to Date.

You don't need anything but the DateTimeConverter, e.g. using the csv you posted

image

I just wonder should I have Date field before using dateformatter transformer? I want to change varchar to Date.

thank you very much

I just wonder should I have Date field before using dateformatter transformer? I want to change varchar to Date.

Hello Ebygomm, the resultant table is as follows: the date field still looks. varchar. I was expecting this field Date, wasn't I?

 

imageimage

Userlevel 1
Badge +21

I just wonder should I have Date field before using dateformatter transformer? I want to change varchar to Date.

To write out as a date you will need to change attribute definition to manual and change the type to date

Reply