tds_fdw icon indicating copy to clipboard operation
tds_fdw copied to clipboard

Incorrect datetime value

Open rentechpro opened this issue 8 years ago • 4 comments

The query below from MS SQL SMS select a_date from dbo.test; shows 2009-11-26 16:42:38.937 2008-05-16 17:29:08.397 (The column a_date defined as datetime in MS SQL.)

But the query select a_date from my.ft_test; from foreign table of PG SQL shows 2009-11-26 16:42:38.937 2008-05-16 18:29:08.397

This column in foreign table defined as timestamp without time zone. Foreign table is defined like this: CREATE FOREIGN TABLE my.ft_test ( ... a_date timestamp without time zone, ... ) SERVER fs_ms_sql OPTIONS (table 'dbo.test');

rentechpro avatar Jan 10 '17 10:01 rentechpro

It looks like Postgres is applying Daylight savings time for some reason :/

bikethis81 avatar Feb 03 '17 20:02 bikethis81

Hi Rentechpro, May I know how you resolved the issue.

I too had a similar issue. In my case, tds_fdw is adding +5:30 (IST) to the date and time fetched from MSSQL. I am also using "timestamp without time zone".

Cheers, Anil

anilv4 avatar Jul 21 '17 16:07 anilv4

Hello guys,

Did you find any solution to this? I'm facing the same issue..

Thanks in advance.

tyrion01 avatar Dec 12 '17 19:12 tyrion01

@rentechpro , @bikethis81, @anilv4, @tyrion01, can you recompile tds_fdw with DEBUG enabled and show us both debug and postgres log when you run the queries (remove confidential parts if needed)?

Just change:

/* #define DEBUG */

to:

/* #define DEBUG */

At file src/tds_fdw.c

Maybe your freetds version could help as well.

juliogonzalez avatar Dec 12 '17 20:12 juliogonzalez