Re: WHERE clause with timestamp data type

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: WHERE clause with timestamp data type
Date: 2007-08-27 05:24:23
Message-ID: 20070827052423.GA13996@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

am Sun, dem 26.08.2007, um 21:49:29 -0700 mailte Chirag Patel folgendes:
> The following command works great,
> SELECT AVG(column) FROM table WHERE timestamp > 2007-08-23;
>
> But when I try it with finer resolution (hour, minutes, seconds) like this, I
> get a syntax error
> SELECT AVG(heartrate) FROM heartrates WHERE timestamp > 2007-08-23 19:48:09;

Can you show us the error?

>
> Do I need to convert from string format to total number of seconds? Any ideas
> on how to get this work?

Try: "WHERE timestamp > '2007-08-23 19:48:09'::timestamp ";

Btw.: bad idea to title a column 'timestamp', because this is a
datatype-identifier - but it works.

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Andrew C. Uselton 2007-08-27 20:18:46 unattended backups
Previous Message Tom Lane 2007-08-27 05:10:50 Re: WHERE clause with timestamp data type