span8
span4
span8
span4
Hi
This might be an easy question!
I have a date field in the format YYYY-MM-DD but I need to convert this into the format DD/MM/YYYY (with the forward slashes).
I have looked at the DateFormatter but there are no formats I need in the destination date format drop down.
Am I able to just reformat it to suit my date above,or are the only options the ones displayed in the drop down?So would (%d/%m/%y) produce my desired date format?
There also appears to be a DateConverter transformer in the FME store but I cannot seem to find out how what formats I can use for this.
Thanks
Hi cartochris,
There is indeed a rather simple solution to your problem.You can simply use an AttributeSplitter to generate a list of your input date and an AttributeCreator using the different elements in the list to generate the new format.
An example is shown in the picture below
Hi
If the DateFormatter does not have the format you're looking for,you can just type it in manually:
Source format: %Y-%m-%d
Destination format: %d/%m/%Y
David
The DateFormatter is a bit sneaky in that it gives you some predefined formats in a picklist,but also allows you to set your own format,which is what you need to do in this case.
Your input format is%Y-%m-%dand your output format is%d/%m/%Y,that should give you the result you want.
Hope this helps.
Wow thanks for the replies everyone,such a helpful place!
On closer inspection,it actually looks like my source data does have the correct date format I need of DD/MM/YYYY,but when I run my workspace without any date transformers,it converts it to YYYY-MM-DD.
So,perhaps I just need to change a workspace variable or something to keep the date in the format as it is on input?Does FME automatically change dates to the Year-Month-Day format?Or would I just need to use the DateFormatter and specify DD/MM/YYYY for both my input and destination formats?(I tried doing automatic detection for input then DD/MM/YYYY for destination but this didn't work).
I should say my source data is from an Oracle table and I am trying to create a PostGIS table.
Presuming that both the source and destination columns are "date" types in the database,FME *should* do the right thing and it should just work.Because dates are so nasty in terms of a wide range of formats,if we detect the source is a date column,we'll format as YYYYMMDD as that data is carried through FME.When we hit the writer,if the destination is a Date type,we'll tell the database to expect a date and format as the database wants.Then you'll see whatever representation you've set as your default when you "Select" from that table.Note that the above again relies on the source/destination data types in the database being dates.If either is a string,more work will be needed...
Thisarticle on FME Dates and Timesis very much worth the read as well.
Thanks both for your responses.
Yes,I investigated further and it looks like the raw source data is in a timestamp field format (although the reader has it as a date format in FME) in the format YYYY-MM-DD HH:MM:SS.
I then tried to use the DateFormatter options to try and get the source data format as above (image shows my setup),but using these parameters it is outputting in the format YYYY-MM-DD.
Not too sure if what I have done is correct?
© 2019 亚搏在线Safe Software Inc |Legal