Skip to main content
Solved

Write timestamp (datetime) with MS SQL JDBC Writer


so_much_more
Supporter
Forum|alt.badge.img+6

I cannot understand why I get the error message

 

MS SQL Server Spatial (JDBC) Writer: Error writing feature. Error: Attribute 'DATECOLLECTED' does not contain a valid timestamp

 

The timestamp I want to write is for the moment hard coded as 2021-07-20.

The databse accept this format confirmed with successful update SQL

 

update dbo.Feature

set "DATECOLLECTED" = '2021-07-20'

where ID = ...

 

Why does FME fail to write to my db? Any suggestions?

Best answer by philipwhitten

Hello @so_much_more​, What is the data type of the field? Is the data type date or datetime? You might need to add a time to your string.

View original
Did this help you find an answer to your question?

4 replies

kailinatsafe
Safer
Forum|alt.badge.img+21

Hello @so_much_more​ , is the writer returning an error at all? Have you tried manually setting a value? Or setting the value with SQL? Best, Kailin.


philipwhitten
Contributor
Forum|alt.badge.img+11
  • Contributor
  • Best Answer
  • July 20, 2021

Hello @so_much_more​, What is the data type of the field? Is the data type date or datetime? You might need to add a time to your string.


so_much_more
Supporter
Forum|alt.badge.img+6
  • Author
  • Supporter
  • July 21, 2021

The datatype is datetime. as @philipwhitten​ mentioned what was missing is to also add time to the string.

So after adding "00:00:00" to the date it worked fine.

I assume SQL Management studio throw that on itself if its missing to match the datatype in the database.


so_much_more
Supporter
Forum|alt.badge.img+6
  • Author
  • Supporter
  • July 21, 2021
kailinatsafe wrote:

Hello @so_much_more​ , is the writer returning an error at all? Have you tried manually setting a value? Or setting the value with SQL? Best, Kailin.

Error from writer was my message "MS SQL Server Spatial (JDBC) Writer: Error writing feature. Error: Attribute 'DATECOLLECTED' does not contain a valid timestamp". I just needed to be a bit more verbose and specific adding time to the record "2021-07-20 00:00:00"


Reply


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