I have a PostgreSQL table with the following schema -
CREATE TABLE test (
id serial NOT NULL PRIMARY KEY,
username varchar(100) NOT NULL, -- The user name
dob timestamp with time zone NOT NULL -- The date of birth
);
I then inserted some data into the table with data like this -
INSERT INTO "test" ("username", "dob") VALUES (E'Scotty', E'2009-05-14 15:44:43');
And if I check the DB for the data, I get this -
mydb=> select username, dob from test where username='Scotty';
username | dob
----------+---------------------------
Scotty | 2009-05-14 15:44:43+05:30
(1 row)
Everything is fine and dandy until I try inserting some data with the date before 1946 -
INSERT INTO "test" ("username", "dob") VALUES (E'James T Kirk', E'1945-01-01 11:30:11');
mydb=> select username, dob from test where username='James T Kirk';
username | dob
-------------- +---------------------------
James T Kirk | 1945-01-01 11:30:11+06:30
(1 row)
Look at the above result. Notice how the Timezone value has changed from +05:30 to +06:30
It actually gets worse when I insert any date which is before 1942 -
INSERT INTO "test" ("username", "dob") VALUES (E'Spock', E'1941-01-01 11:30:11');
mydb=> select username, dob from test where username='Spock';
username | dob
----------+------------------------------
Spock | 1941-01-01 11:30:11+05:53:20
(1 row)
Now the Timezone value has got completely mangled and the date can't be parsed.
I would appreciate any help with this.
My Timezone is Asia/Kolkata (GMT+05:30).
Update: I tried entering the data by specifying the TZ explicitly like this -
INSERT INTO "test" ("username", "dob") VALUES (E'McCoy', E'1941-01-25 00:20:30+05:30');
Even then it didn't work.
mydb=> select username, dob from test where username='McCoy';
username | dob
----------+------------------------------
McCoy | 1941-01-25 00:43:50+05:53:20
(1 row)