Re: Lexical question...

From: John DeSoi <desoi(at)pgedit(dot)com>
To: "Net Virtual Mailing Lists" <mailinglists(at)net-virtual(dot)com>
Cc: "Pgsql General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Lexical question...
Date: 2004-11-23 14:03:26
Message-ID: 71F80564-3D58-11D9-AAD7-000A95B03262@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Nov 23, 2004, at 5:33 AM, Net Virtual Mailing Lists wrote:

> I have a table with a timestamp column and I want to set this to a
> value
> of now() - a random number of days between 0 and 45 for each row...
> I've
> tried to do this a bunch of different ways and can't figure it out...
> Here is my latest version:
>
>
> update sometable set entered_dt = now() - interval
> round(random()*45)||'
> days';
>

Try

select now() - ((round(random()*45))::text || ' days')::interval;

Best,

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jerry LeVan 2004-11-23 14:49:05 Will B4->B5 require an Initdb?
Previous Message Pawe Niewiadomski 2004-11-23 12:38:13 bitmap index