Skip to main content

I have the following table in SQL Server 2016

CREATE TABLE [dbo].[new_tasks](

[id] [uniqueidentifier] NOT NULL,

[reportedDate] [datetimeoffset](7) NOT NULL

)

 

When I run the following SQL in MS SQL Server Management Studio or via an SQLExecutor it correctly inserts the time value into the database.

 

INSERT INTO new_tasks(sid],]reportedDate]) VALUES ('F59DA401-DE8F-4F3C-A60C-018008D81527','2019-10-24T13:57:48.076178+11:00')

 

I.E When querying the record the reportedDate will be returned as '2019-10-24 13:57:48.076178+11:00'

 

But if I try and insert the values using the FeatureWriter it will zero out the offset, I.E. reportedDate will be returned as '2019-10-24 13:57:48.076178+00:00'

 

Converting the datetime string in a workbench to FME datetime or FME datetime with offset, correctly transforms it inside the workbench, but it will still zero out the offset value when I use the FeatureWriter to insert it into the database table.

 

Does anyone know how to fix this? (The reason I want to use the FeatureWriter is due to wanting to use the fme_db_operation and because it handles a lot of issues (such as a ' in a notes field or extra fields existing in the data that doesn't have a matching column in the SQL table).

 

Alternatively, does anyone know how I can see the SQL generated by the FeatureWriter 9I'm using the Microsoft SQL Server Non-Spatial (JDBC) driver...so perhaps it generates java code instead? Is this viewable somehow? (I tried turning on debug logging, but saw nothing useful).

 

Edit: Just adding this for anyone else that has this issue. This has been recognised by Safe as a bug, the work around I was given in the mean time is to use the MSSQL_ADO format until it is fixed (this doesn't work for me as I need NVARCHAR(MAX) access, which is currently only available via the JDBC writer).

 

I will update/reply to this once I have been notified that it is fixed.

@nmartin​  When you use an FME writer to write out date/time values, you need to convert the date format to the FME Date/Time format. A bit more on working with date/time in FME in this tutorial.


@nmartin​  When you use an FME writer to write out date/time values, you need to convert the date format to the FME Date/Time format. A bit more on working with date/time in FME in this tutorial.

Hi @Mark Stoakes​ ,

 

As mentioned, I have tried the DateTimeConverter transformer. It will correctly change the reportedDate to '20191024135748.076178+11:00' but when this gets inserted into the database it sets the offset to +00:00.


Reply