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

Re: Comparing times to "now + 45 seconds"

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Comparing times to "now + 45 seconds"
Date: 2010-01-24 10:28:17
Message-ID: hjh7bv$8eb$1@ger.gmane.org (view raw or flat)
Thread:
Lists: pgsql-novice
Rikard Bosnjakovic wrote on 24.01.2010 11:08:
> I want to compare these times to the actual (current) time + 45
> seconds. If the current time + 45 seconds is higher than the time in
> the table, I want "true". First, I tried this:
>
> # select times, times>  now()::time AS time_compare from live_stats;
[...]

> Which works, but I don't know how to apply the "45 seconds":
>
> # select times, times>  (now()::time + '45 seconds') AS time_compare
> from live_stats;

You need to add an interval.

This should work:

SELECT times, times > (now()::time + interval '45' second) as time_compare
FROM live_stats;


Regards
Thomas


In response to

Responses

pgsql-novice by date

Next:From: Rikard BosnjakovicDate: 2010-01-24 11:10:50
Subject: Re: Comparing times to "now + 45 seconds"
Previous:From: Jean-Yves F. BarbierDate: 2010-01-24 10:19:03
Subject: Re: Comparing times to "now + 45 seconds"

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