On 12-02-2021 21:34, Vlad Khorsun wrote:
12.02.2021 18:04, Dimitry Sibiryakov wrote:
   Hello All.

   I'm trying to get current timestamp without time zone in UTC without messing with session settings but... I cannot figure out how to.

   "localtimestamp" results in timestamp in current time zone.
   "localtimestamp at time zone 'UTC'" results in timestamp with time zone.    "cast(localtimestamp at time zone 'UTC' as timestamp without time zone)" results in timestamp in current time zone again.    Syntax "cast(current_timestamp as timestamp without time zone at time zone 'UTC')" does not exist.

   Any idea?


   For UTC you may try something like

    dateadd(hour, -extract(timezone_hour from localtimestamp), localtimestamp)

That wouldn't be sufficient, you would need:

dateadd(minute, -extract(timezone_minute from (dateadd(hour, -extract(timezone_hour from original), value))

Maybe we need a TRUNCATE_TIME_ZONE function, which for a TIME/TIMESTAMP WITH TIME ZONE will return a WITHOUT TIME ZONE equivalent with the same wallclock time.

Mark
--
Mark Rotteveel


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to