Re: Adding 1 week to a timestamp, which can be NULL or expired

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Adding 1 week to a timestamp, which can be NULL or expired
Date: 2011-11-20 10:38:36
Message-ID: 4EC8D8AC.1080908@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/20/11 2:32 AM, Alexander Farber wrote:
> update pref_users set vip = max(vip, now()) + interval '1 week';
>
> but max() doesn't work with timestamps.

max works fine with timestamps... however, its a 1 argument function
that takes an aggregate as its argument.

you perhaps want GREATEST(val1,val2)

update pref_users set vip = greatest(vip, now()) + interval '1 week';

--
john r pierce N 37, W 122
santa cruz ca mid-left coast

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marko Kreen 2011-11-20 11:21:11 Re: Installed. Now what?
Previous Message Alexander Farber 2011-11-20 10:32:42 Adding 1 week to a timestamp, which can be NULL or expired