From rdear@gameszone.net Mon Mar 29 10:52:13 1999 Received: from kosh. (ba6.icl.net [194.176.201.1]) by hub.org (8.9.2/8.9.1) with SMTP id FAA67006 for ; Mon, 29 Mar 1999 05:52:13 -0500 (EST) (envelope-from rdear@gameszone.net) Received: from gameszone.net by kosh. (SMI-8.6/SMI-SVR4) id KAA12650; Mon, 29 Mar 1999 10:51:37 GMT Sender: rdear@gameszone.net Message-ID: <36FF5B39.52CB4137@gameszone.net> Date: Mon, 29 Mar 1999 10:51:37 +0000 From: Rick Dearman Reply-To: rick@ricken.demon.co.uk X-Mailer: Mozilla 4.5 [en] (X11; I; SunOS 5.6 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-general@postgresql.org Subject: Returning an integer from a date Content-Type: multipart/alternative; boundary="------------06D4C532668FEF034E6B1134" --------------06D4C532668FEF034E6B1134 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I have a date field in a table, I want to create a function to manipulate this date, however I want the date to come to me as an integer. Is this possible? Or do I have to get it as a char *string?? -- It said use Windows 95 or better, so I installed Linux! --------------06D4C532668FEF034E6B1134 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit I have a date field in a table, I want to create a function to manipulate this date, however I want the date to come to me as an integer.

Is this possible? Or do I have to get it as a char *string??
 
 

-- 
It said use Windows 95 or better, so I installed Linux!
  --------------06D4C532668FEF034E6B1134-- From a.joubert@albourne.com Mon Mar 29 11:22:42 1999 Received: from cap-ferrat.albourne.com (IDENT:root@cap-ferrat.albourne.com [195.89.178.227]) by hub.org (8.9.2/8.9.1) with ESMTP id GAA71487 for ; Mon, 29 Mar 1999 06:22:42 -0500 (EST) (envelope-from a.joubert@albourne.com) Received: from albourne.com (akamas.albourne.com [195.212.241.254]) by cap-ferrat.albourne.com (8.9.3/8.9.3/Albourne/2.4) with ESMTP id MAA06022; Mon, 29 Mar 1999 12:22:37 +0100 (BST) Sender: a.joubert@albourne.com Message-ID: <36FF626F.EA9E6B63@albourne.com> Date: Mon, 29 Mar 1999 12:22:23 +0100 From: Adriaan Joubert Organization: APL Financial Services (Overseas) Ltd X-Mailer: Mozilla 4.5 [en] (X11; U; OSF1 V4.0 alpha) X-Accept-Language: en MIME-Version: 1.0 To: rick@ricken.demon.co.uk CC: pgsql-general@postgreSQL.org Subject: Re: [GENERAL] Returning an integer from a date References: <36FF5B39.52CB4137@gameszone.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Rick Dearman wrote: > > I have a date field in a table, I want to create a function to > manipulate this date, however I want the date to come to me as an > integer. > > Is this possible? Or do I have to get it as a char *string?? > Get it in a binary cursor and you can get it as a julian date (centred around 2000). I handle all my dates as integers. Adriaan From herouth@oumail.openu.ac.il Mon Mar 29 15:58:31 1999 Received: from mx99.openu.ac.il (arbel.openu.ac.il [147.233.32.4]) by hub.org (8.9.2/8.9.1) with ESMTP id KAA00870 for ; Mon, 29 Mar 1999 10:58:31 -0500 (EST) (envelope-from herouth@oumail.openu.ac.il) Received: from talmon.openu.ac.il (talmon.openu.ac.il [147.233.32.11]) by mx99.openu.ac.il (Postfix) with ESMTP for id 077984B4AE; Mon, 29 Mar 1999 15:58:24 +0000 (Asia/Jerusalem) Received: from [147.233.148.145] (1169.pc.openu.ac.il) by talmon.openu.ac.il (Netscape Messaging Server 3.54) with ESMTP id AAA5DC; Mon, 29 Mar 1999 18:00:12 +0200 X-Sender: herouth@shaked.cc.openu.ac.il Message-Id: In-Reply-To: <36FF5B39.52CB4137@gameszone.net> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Date: Mon, 29 Mar 1999 18:00:00 +0200 To: rick@ricken.demon.co.uk, pgsql-general@postgreSQL.org From: Herouth Maoz Subject: Re: [GENERAL] Returning an integer from a date Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by hub.org id KAA00872 At 12:51 +0200 on 29/03/1999, Rick Dearman wrote: > > I have a date field in a table, I want to create a function to >manipulate this date, however I want the date to come to me as an integer. > > Is this possible? Or do I have to get it as a char *string?? What kind of an integer do you need? You could have the "milliseconds since epoch" kind of number quite easily. Or do you need a number such as 19990301? Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma From herouth@oumail.openu.ac.il Tue Mar 30 11:49:36 1999 Received: from mx99.openu.ac.il (arbel.openu.ac.il [147.233.32.4]) by hub.org (8.9.2/8.9.1) with ESMTP id GAA26269 for ; Tue, 30 Mar 1999 06:49:36 -0500 (EST) (envelope-from herouth@oumail.openu.ac.il) Received: from talmon.openu.ac.il (talmon.openu.ac.il [147.233.32.11]) by mx99.openu.ac.il (Postfix) with ESMTP for id 3063E4B520; Tue, 30 Mar 1999 11:49:35 +0000 (Asia/Jerusalem) Received: from [147.233.148.140] (1164.pc.openu.ac.il) by talmon.openu.ac.il (Netscape Messaging Server 3.54) with ESMTP id AAA19EC; Tue, 30 Mar 1999 13:51:21 +0200 X-Sender: herouth@shaked.cc.openu.ac.il Message-Id: In-Reply-To: <36FFE017.9E1F65A2@ricken.demon.co.uk> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Tue, 30 Mar 1999 13:51:16 +0200 To: Rick Dearman From: Herouth Maoz Subject: Re: [GENERAL] Returning an integer from a date Cc: pgsql-sql@postgreSQL.org At 22:18 +0200 on 29/03/1999, Rick Dearman wrote: > > I want the number of seconds since 1970 Basically, the function date_part( 'epoch', expression_of_datetime_type ) returns the number of seconds since 1970. But it returns a float, not an integer, because datetimes can include milliseconds etc. For example: testing=> select date_part( 'epoch' , '1999-03-01 07:38:01.10'::datetime); date_part ----------- 920266681.1 (1 row) So, you may either write your program to expect a float there (float8), or you can force it to be an integer using the function int() around the date_part function. But then you lose the milliseconds. Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma