Re: unix time -> timestamp

From: boyd <tbmoore(at)bealenet(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: unix time -> timestamp
Date: 2004-01-06 23:36:41
Message-ID: tbmoore-DCAAA3.18364106012004@news.ispnews.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

In article <tbmoore-54811A(dot)18291606012004(at)news(dot)ispnews(dot)com>,
boyd <tbmoore(at)bealenet(dot)com> wrote:

> I'm pretty sure in 7.0 postgres, (but I may be wrong) you could insert
> directly from a perl script something like this:
> $time = time; # this gives epoch seconds
> $sql = "insert into mytable values(..., timestamp($time), ...) ";
>
> And then the $sql string would run with the DBI call, etc.
>
> When I tried the same script on 7.2, it would not take it. I think I
> once found another way to do it in 7.2. Of course, I can create a
> formatted string in perl that will be accepted by the insert, but it
> seems inefficient to have to do it through strings.
>
> Boyd tbmooreATbealenetDOTcom

Sorry - five minutes later, I found it -

You just use abstime as the function to convert, as in:

"insert into mytable values(..., abstime($time), ...) ";

Boyd tbmooreATbealenetDOTcom

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Loeke 2004-01-06 23:38:08 question : the choice of the primary key.
Previous Message boyd 2004-01-06 23:29:16 unix time -> timestamp