pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
'now - 4 hours ago' ?
3+ messages / 3 participants
[nested] [flat]

* 'now - 4 hours ago' ?
@ 1998-06-18 17:26  Petter Reinholdtsen <pere@hungry.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Petter Reinholdtsen @ 1998-06-18 17:26 UTC (permalink / raw)
  To: pgsql-sql


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!




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [SQL] 'now - 4 hours ago' ?
@ 1998-06-19 06:10  Zsolt Varga <redax@agria.hu>
  parent: Petter Reinholdtsen <pere@hungry.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Zsolt Varga @ 1998-06-19 06:10 UTC (permalink / raw)
  To: Petter Reinholdtsen <pere@hungry.com>; +Cc: pgsql-sql

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/  |
`----------------------------------------------------------'




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* RE: [SQL] 'now - 4 hours ago' ?
@ 1998-06-19 17:22  Jackson, DeJuan <djackson@cpsgroup.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Jackson, DeJuan @ 1998-06-19 17:22 UTC (permalink / raw)
  To: Zsolt Varga <redax@agria.hu>; Petter Reinholdtsen <pere@hungry.com>; +Cc: pgsql-sql

> 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
> 
DATETIME has more features and a wider range than TIMESTAMP, so if I
were you that's what I'd be using.
try: SELECT NOW()::DATETIME - '@4 hours'::TIMESPAN;
I suggest sticking with DATETIME as much as you can.
		-DEJ



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~1998-06-19 17:22 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-06-18 17:26 'now - 4 hours ago' ? Petter Reinholdtsen <pere@hungry.com>
1998-06-19 06:10 ` Zsolt Varga <redax@agria.hu>
1998-06-19 17:22 RE: [SQL] 'now - 4 hours ago' ? Jackson, DeJuan <djackson@cpsgroup.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox