tags:

views:

34

answers:

1

Simple question (I hope):

I have a simple two column table, a measurement and the time the measurement was taken. How can I select all of the measurements taken at 30 minutes past the hour? Although these measurements are supposed to be made at a regular interval (every 15 minutes in this case), there are often gaps in the data.

Sample table:

       value   |      obstime
-------------------------------------
        1.1    |  2010-08-13 14:00:00
        1.2    |  2010-08-13 13:45:00
        1.3    |  2010-08-13 13:30:00
        1.4    |  2010-08-13 12:30:00
        1.5    |  2010-08-13 12:00:00
        2.2    |  2010-08-13 09:30:00
        ...    |         .....

In this example, I am trying extract the third, fourth, and sixth rows of the table. Note the gaps in what is supposed to be a regular 15 minutes interval.

I'm using postgresql v. 8.2.6, by the way.

+2  A: 

http://www.postgresql.org/docs/8.0/interactive/functions-datetime.html

SELECT FROM table WHERE EXTRACT(MINUTE FROM TIMESTAMP field) = 30;
Scott Saunders