Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update a datetime field with timezone in postgresql

Tags:

postgresql

As the question states i tried

UPDATE mytable set end_date="2015-07-17 22:00:00+00" WHERE id=8244;

But this does not work for obvious reasons, all the detail on the web is about searching for dates not updating them, especially when they have timezones

like image 736
Mr Mixin Avatar asked Jul 20 '15 08:07

Mr Mixin


People also ask

How does Postgres store timestamp with timezone?

The timestamptz datatype is a time zone-aware date and time data type. PostgreSQL stores the timestamptz in UTC value. When you insert a value into a timestamptz column, PostgreSQL converts the timestamptz value into a UTC value and stores the UTC value in the table.


1 Answers

UPDATE mytable set end_date='2015-07-17 22:00:00+00' WHERE id=8244;
like image 68
Ispirer SQLWays Migrations Avatar answered Oct 16 '22 05:10

Ispirer SQLWays Migrations