Adding to a date/time?

From: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Adding to a date/time?
Date: 2002-09-19 08:09:10
Message-ID: 3D898626.2000403@mega-bucks.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm having some trouble understanding the behaviour of one of my queries
on version 7.2. I'm sure it's because I don't understand date/times ...
Here is the query I don't understand and it's results
:
$ psql TMP -c "select id, req_del_date3 from invoices order by id"
id | req_del_date3
----+------------------------
1 | 2002-09-18 00:00:00+09
10 | 2002-09-18 00:00:00+09
13 | 2002-09-18 00:00:00+09
17 | 2002-09-18 00:00:00+09

$ psql TMP -c "update invoices set req_del_date3='today+8' where id > 10"
UPDATE 2
$ psql TMP -c "select id, req_del_date3 from invoices order by id"
id | req_del_date3
----+------------------------
1 | 2002-09-18 00:00:00+09
10 | 2002-09-18 00:00:00+09
13 | 2002-09-18 01:00:00+09
17 | 2002-09-18 01:00:00+09

Why does 'today+8' add 1 hour to the timestamp? I could have
understanding adding 8 secs, 8 hours, 8 days, or 8 of anything but it
added 1 hour? What did I miss?

I also tried this with the same results (I assumed 8d would force adding
8 *days* but no ...):

$ psql TMP -c "update invoices set req_del_date3='today+8d' where id > 10"

What does postgresQL think 8d means?

And finally what is the proper SQL to add 8days to a timestamp?

Jc

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Christian Imbeault 2002-09-19 08:43:40 Re: IN vs EXIIST
Previous Message Jean-Christian Imbeault 2002-09-19 07:58:47 datetime(): Where is it in the docs?