Обсуждение: 'now - 4 hours ago' ?

Поиск
Список
Период
Сортировка

'now - 4 hours ago' ?

От
Petter Reinholdtsen
Дата:
I'm still learning SQL. :-)

Now I have upgraded my PostgreSQL database to v6.3.2, and have the
following table.

  CREATE TABLE testdate(
       received timestamp DEFAULT CURRENT_DATE,
       info text NOT NULL
       );

I want to select the info received (inserted) more then 4 hours ago.
How do I specify that in SQL?  Is timestamp the best datatype for this
kind of query?  Which date-types exists in PostgreSQL, and what is the
difference between them.  I'll be very happy to get pointers to good
intros. :-)

I'm not on this list, so please send copies to me.
--
##>  Petter Reinholdtsen <##    | pere@td.org.uit.no
 O-  <SCRIPT Language="Javascript">window.close()</SCRIPT>
http://www.hungry.com/~pere/    | Go Mozilla, go! Go!


Re: [SQL] 'now - 4 hours ago' ?

От
Zsolt Varga
Дата:
On Thu, 18 Jun 1998, Petter Reinholdtsen wrote:

|  CREATE TABLE testdate(
|       received timestamp DEFAULT CURRENT_DATE,
|       info text NOT NULL
|       );

I think CURRENT_DATE will be parsed to the table creation's time.
so better to use:

    CREATE TABLE testdate (
        received timestamp DEFAULT timestamp(now()),
        info     text      NOT NULL
        );

    Redax

.----------------------------------------------------------.
|Zsolt Varga            | tel/fax:   +36 36 422811         |
| AgriaComputer LTD     | email:     redax@agria.hu        |
| System Administrator  | URL:       http://www.agria.hu/  |
`----------------------------------------------------------'