Skip site navigation (1) Skip section navigation (2)

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: (view raw, whole thread or download thread mbox)
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 Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA

In response to

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group