Skip to main content
Question

How to write 4 digit year to MySQL database with field type year(4)


tara_he
Contributor
Forum|alt.badge.img+4

I am trying to write a 4 digit year into an existing MySQL database. The field type is year with a length of 4. Therefore, one would think that a 4 digit integer would write into it, but it does not. I get a warning saying "MySQL Writer: Skipped feature due to invalid date/time string". This seems extremely basic, but how do I turn a4 digit integer (e.x. 2012) into a date field that MySQL will recognize as a year?

2 replies

rahulsharma
Safer
Forum|alt.badge.img+10

Hi @Tara Preston​ 

In order to write year(4) to MariaDB or MySQL database, the incoming attribute has to be structured as either FME date or ISO date. You can use the DateTimeFormatter transformer to do this.

 

image 


tara_he
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • May 13, 2022

Thanks @rahulsharma​ for the quick response. I actually just found a workaround. I had been trying a DateTimeFormatter, but it wasn't working since the feature needing formatted was just a Year. To work around this, I simply used an AttributeManager or AttributeCreator and added a fake month and date to the end of the year (@Value(YR)0101). I didn't even have to use a DateTimeFormatter after this as it was already formatted. Again, thank you for the response though.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings