Re: Comparing times to "now + 45 seconds" - Mailing list pgsql-novice

From Thomas Kellerer
Subject Re: Comparing times to "now + 45 seconds"
Date
Msg-id hjh7bv$8eb$1@ger.gmane.org
Whole thread Raw
In response to Comparing times to "now + 45 seconds"  (Rikard Bosnjakovic <rikard.bosnjakovic@gmail.com>)
Responses Re: Comparing times to "now + 45 seconds"  (Rikard Bosnjakovic <rikard.bosnjakovic@gmail.com>)
List 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

pgsql-novice by date:

Previous
From: "Jean-Yves F. Barbier"
Date:
Subject: Re: Comparing times to "now + 45 seconds"
Next
From: Rikard Bosnjakovic
Date:
Subject: Re: Comparing times to "now + 45 seconds"