Discussion:
partial time stamp query
(too old to reply)
Kirk Wythers
2013-02-04 14:45:33 UTC
Permalink
I am trying to write a query that grabs one particular day from a timestamp column. The data are ordered in 15 minute chunks like this:

2010-07-07 12:45:00
2010-07-07 13:00:00
2010-07-07 13:15:00
2010-07-07 13:30:00
etc…

If I wanted all records from july 7th 2010, I would expect 4 x 24 = 96 records per day.

I have tried the '=' operator, like this

WHERE derived_tsoil_fifteen_min_stacked.time2 = '2010-07-07*'

but that grabs nothing, and using the '~' operator grabs everything with a 2010 or 07 in it… in other words all days from July of 2010.

Any suggestions would be much appreciated.
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Moshe Jacobson
2013-02-05 01:26:36 UTC
Permalink
Post by Kirk Wythers
I am trying to write a query that grabs one particular day from a
2010-07-07 12:45:00
2010-07-07 13:00:00
2010-07-07 13:15:00
2010-07-07 13:30:00
etc…
WHERE derived_tsoil_fifteen_min_stacked.time2 = '2010-07-07*'
but that grabs nothing
Just cast the timestamp to a date before you compare it:

WHERE derived_tsoil_fifteen_min_stacked.time2::date = '2010-07-07'
--
Moshe Jacobson
Nead Werx, Inc. | Manager of Systems Engineering
2323 Cumberland Parkway, Suite 201 | Atlanta, GA 30339
***@neadwerx.com | www.neadwerx.com

"People don't multitask because they're good at it. They do it because they
are more distracted" -- David
Sanbonmatsu<http://www.plosone.org/article/info%3Adoi%2F10.1371%2Fjournal.pone.0054402>
Loading...