Cannot set TimeZoneOffset on AsPgTimeStamp

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tristan
Posts: 2
Joined: Thu 29 Nov 2018 06:31

Cannot set TimeZoneOffset on AsPgTimeStamp

Post by tristan » Thu 29 Nov 2018 06:59

Hi, I am inserting into a table where one of the columns is of type timestamptz (timestamp with time zone).

The problem occurs where I am just setting the param values of the query.

In my delphi code:

Code: Select all

Query.ParamByName('datetime').AsPgTimeStamp.TimeZoneOffset := 0;
I would like to do this. But TimeZoneOffset is read only, cannot set value here. Where interestingly you can for PgTime. I.e.

Code: Select all

Query.ParamByName('datetime').AsPgTime.TimeZoneOffset := 0;
Is it intended not too be able to write to AsPgTimeStamp.TimeZoneOffset? As I cannot see any way for this to be set. (Other than setting via a string).

It is just strange when HasTimeZone is settable for AsPgTimeStamp, and that TimeZoneOffset is settable for AsPgTime.

I can work around with formatting strings. But it would be nice to be able to specify numerically.

I can see the value is initialised to the local time of the machine. So one could work with that. I want to insert as UTC, but i can convert back to local time then insert using this. Just seems haphazard.

Is this a known issue? Or am I just going about this in the wrong way? (E.g. it is only intended to be populated via the dataset or other means and to be read only. But then why can we set HasTimeZone?).

Thanks!

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Cannot set TimeZoneOffset on AsPgTimeStamp

Post by azyk » Thu 29 Nov 2018 13:33

Thank you for the information.

We will investigate this behavior of TCustomPgTimeStamp.TimeZoneOffset and will let you know the results.

Tiedo000
Posts: 2
Joined: Tue 02 Jun 2020 14:07

Re: Cannot set TimeZoneOffset on AsPgTimeStamp

Post by Tiedo000 » Tue 02 Jun 2020 15:19

In version 6.1.3 this problem seems stil not to be solved. It's clear in the sourcecode: TPgTime.TimeZoneOffset is a readwrite property, TPgTimeStamp.TimeZoneOffset is readonly.

When can we expect a bugfix? Is there a workaround?

Tiedo000
Posts: 2
Joined: Tue 02 Jun 2020 14:07

Re: Cannot set TimeZoneOffset on AsPgTimeStamp

Post by Tiedo000 » Wed 03 Jun 2020 07:16

It looks like TPgParam.AsSQLTimeStampOffset does not work either (AsSQLTimeStamp does).
Is there any way at all to use the PostgreSQL type "timestamp with time zone" with PgDAC?

oleg0k
Devart Team
Posts: 81
Joined: Wed 11 Mar 2020 08:28

Re: Cannot set TimeZoneOffset on AsPgTimeStamp

Post by oleg0k » Mon 15 Jun 2020 09:55

Hello,
In order to get a detailed answer, please compose a small sample demonstrating the specified behavior and send it to us including scripts for creating and filling database objects.

wbr, Oleg
Devart Team

Post Reply