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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-novice by date

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