Skip to main content
Solved

Write timestamp (datetime) with MS SQL JDBC Writer

  • July 20, 2021
  • 4 replies
  • 52 views

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

kailinatsafe
Safer
Forum|alt.badge.img+23
  • Safer
  • 720 replies
  • July 20, 2021

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
Supporter
Forum|alt.badge.img+15
  • Supporter
  • 50 replies
  • 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
  • 46 replies
  • 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
  • 46 replies
  • July 21, 2021

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"