“Postgres insira o carimbo de data e hora sem fuso horário” Respostas de código

Postgres insira o carimbo de data e hora sem fuso horário


            
                
            
         INSERT INTO timestamp_demo (ts, tstz)
VALUES('2016-06-22 19:10:25-07','2016-06-22 19:10:25-07');Code language: SQL (Structured Query Language) (sql)
Determined Donkey

PostgreSQL Alterar o fuso horário no timestamp sem fuso horário

-- You have an issue where entries in the database are recorded in local time without the timezone
-- Postgresql assumes that these entries are in fact UTC
-- This corrects these entries by converting them to actual UTC
-- You might want to update the column (from timestamp) to a timestamptz, then perform the command below
UPDATE <table>
SET <timestamptz_field> = 
  (<timestamptz_field> AT TIME ZONE 'UTC') AT TIME ZONE '<correct_time_zone>';
  
-- e.g start_date_time before = '2021-07-29 18:15:16+00' (This is from a location at GMT+2)
-- start_date_time after = '2021-07-29 16:15:16+00' (This is the actual UTC timestamp)
UPDATE public.uut_result
	SET start_date_time= (start_date_time at time zone 'utc') at time zone 'Africa/Harare'
Muddy Moose

Respostas semelhantes a “Postgres insira o carimbo de data e hora sem fuso horário”

Perguntas semelhantes a “Postgres insira o carimbo de data e hora sem fuso horário”

Procure respostas de código populares por idioma

Procurar outros idiomas de código