pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to filter on timestamps?
2+ messages / 2 participants
[nested] [flat]

* How to filter on timestamps?
@ 2004-07-06 18:37  B.W.H. van Beest <bwvb@xs4all.nl>
  0 siblings, 1 reply; 2+ messages in thread

From: B.W.H. van Beest @ 2004-07-06 18:37 UTC (permalink / raw)
  To: pgsql-sql



I have a table where one of the columns is of type 'TIMESTAMP'

How can I do a query to filter on the TIMESTAMP value, e.g. to obtain 
all rows earlier than a certain time stamp?

Regards,



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

* Re: How to filter on timestamps?
@ 2004-07-07 03:28  Mike Rylander <miker@purplefrog.com>
  parent: B.W.H. van Beest <bwvb@xs4all.nl>
  0 siblings, 0 replies; 2+ messages in thread

From: Mike Rylander @ 2004-07-07 03:28 UTC (permalink / raw)
  To: B.W.H. van Beest <bwvb@xs4all.nl>

<posted & mailed>

B.W.H. van Beest wrote:

> 
> 
> I have a table where one of the columns is of type 'TIMESTAMP'
> 
> How can I do a query to filter on the TIMESTAMP value, e.g. to obtain
> all rows earlier than a certain time stamp?

Think of the math opperators '<' and '>' as 'before' and 'after',
respectively.  ie:

SELECT * FROM table WHERE begin_date > '2004-07-06';

You can also use BETWEEN:

SELECT * FROM table WHERE update_timestamp BETWEEN '2004-07-01' AND
'2004-07-06';

Remember that when timestamps are cast to dates, they are cast with
00:00:00.0 as the time part.

See the docs on this at
http://www.postgresql.org/docs/7.4/interactive/datatype-datetime.html and
http://www.postgresql.org/docs/7.4/interactive/functions-datetime.html .

--miker
> 
> Regards,




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


end of thread, other threads:[~2004-07-07 03:28 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-07-06 18:37 How to filter on timestamps? B.W.H. van Beest <bwvb@xs4all.nl>
2004-07-07 03:28 ` Mike Rylander <miker@purplefrog.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