pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedunix time -> timestamp
2+ messages / 1 participants
[nested] [flat]
* unix time -> timestamp
@ 2004-01-06 23:29 boyd <tbmoore@bealenet.com>
2004-01-06 23:36 ` Re: unix time -> timestamp boyd <tbmoore@bealenet.com>
0 siblings, 1 reply; 2+ messages in thread
From: boyd @ 2004-01-06 23:29 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: unix time -> timestamp
2004-01-06 23:29 unix time -> timestamp boyd <tbmoore@bealenet.com>
@ 2004-01-06 23:36 ` boyd <tbmoore@bealenet.com>
0 siblings, 0 replies; 2+ messages in thread
From: boyd @ 2004-01-06 23:36 UTC (permalink / raw)
To: pgsql-sql
In article <tbmoore-54811A.18291606012004@news.ispnews.com>,
boyd <tbmoore@bealenet.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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-01-06 23:36 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-01-06 23:29 unix time -> timestamp boyd <tbmoore@bealenet.com>
2004-01-06 23:36 ` boyd <tbmoore@bealenet.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox