X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3FDECD1B4D4 for ; Wed, 7 Jan 2004 00:05:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 10302-01 for ; Tue, 6 Jan 2004 20:04:43 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 926FED1B473 for ; Tue, 6 Jan 2004 20:04:39 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i0704dU6085537 for ; Wed, 7 Jan 2004 00:04:39 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i06NamRP068522 for pgsql-sql@postgresql.org; Tue, 6 Jan 2004 23:36:48 GMT From: boyd X-Newsgroups: comp.databases.postgresql.sql Subject: Re: unix time -> timestamp References: User-Agent: MT-NewsWatcher/3.2 (PPC Mac OS X) Message-ID: Lines: 24 X-Complaints-To: abuse@usenetserver.com X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly. Date: Tue, 06 Jan 2004 18:36:41 -0500 To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/52 X-Sequence-Number: 16445 In article , boyd 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