X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 575AE5E37CE for ; Fri, 13 Aug 2004 11:44:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80839-07 for ; Fri, 13 Aug 2004 14:44:33 +0000 (GMT) Received: from sigurd.incentre.net (unknown [206.75.213.195]) by svr1.postgresql.org (Postfix) with ESMTP id E05E85E46DD for ; Fri, 13 Aug 2004 11:44:30 -0300 (ADT) Received: from incentre.net (sigurd.incentre.net [127.0.0.1]) by sigurd.incentre.net (8.12.10/8.12.10) with ESMTP id i7DEiXZU004186; Fri, 13 Aug 2004 08:44:34 -0600 Message-ID: <411CD3D1.2090800@incentre.net> Date: Fri, 13 Aug 2004 08:44:33 -0600 From: Guy Fraser Organization: The Internet Centre User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040124 X-Accept-Language: en-ca, en-gb, en-us, en MIME-Version: 1.0 To: "Pradeepkumar, Pyatalo (IE10)" Cc: pgsql-novice@postgresql.org Subject: Re: [SQL] how to cast localtimestamp to bigint??? References: <77ED2BF75D59D1439F90412CC5B109741027FF0F@ie10-sahara.hiso.honeywell.com> In-Reply-To: <77ED2BF75D59D1439F90412CC5B109741027FF0F@ie10-sahara.hiso.honeywell.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/164 X-Sequence-Number: 10701 You don't need to use a bigint, read the documentation on data types. There are a number of different things you can use for a timestamp, here are a few : abstime abstime with timezone timestamp timestamp with timezone Then when you are inserting your data, you can use 'now' as the time. Eg. CREATE TABLE pointy_stuff ( PointId integer, PointName varchar(50), PointType integer, CreateTime abstime ); INSERT INTO pointy_stuff ( PointId, PointName, PointType, CreateTime ) VALUES ( '12345', 'point1', '1', 'now' ); I believe abstime is the smallest timestamp, but I could be wrong. To output the data as a bigint I believe you can use this. SELECT PointId, PointName, PointType, date_part('epoch',CreateTime) as unix_ts FROM pointy_stuff ; Hope that helps. Pradeepkumar, Pyatalo (IE10) wrote: >Hi, > >I am having a table something like this.... > >CREATE TABLE(PointId integer, PointName varchar(50),PointType integer, >createtime bigint); > >where createtime is the current timestamp when the tuple is inserted. > >now how do I insert values into the above table. Is there a way to cast >timestamp to bigint. >Also can anyone suggest as to which date function to use - >CURRENT_TIMESTAMP, LOCALTIMESTAMP, timeofday(), now.... > > >