Received: from tomts9-srv.bellnexxia.net (tomts9.bellnexxia.net [209.226.175.53]) by postgresql.org (Postfix) with ESMTP id 0005D4766EA for ; Tue, 26 Feb 2002 14:41:39 -0500 (EST) Received: from ACER ([65.94.208.85]) by tomts9-srv.bellnexxia.net (InterMail vM.4.01.03.23 201-229-121-123-20010418) with SMTP id <20020226194140.DEWA12383.tomts9-srv.bellnexxia.net@ACER>; Tue, 26 Feb 2002 14:41:40 -0500 Message-Id: <3.0.6.32.20020226143834.007be200@pop6.sympatico.ca> X-Sender: b1wudu74@pop6.sympatico.ca X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Tue, 26 Feb 2002 14:38:34 -0500 To: panjas51@yahoo.fr (panjas51) From: Frank Bax Subject: Re: [CHALLANGE] Add seconds to a date Cc: pgsql-sql@postgresql.org In-Reply-To: <3c1b889f.0202250816.298b7afd@posting.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Archive-Number: 200202/409 X-Sequence-Number: 6831 PGSQL has this functionality built-in, but it is implemented with operators, not functions: http://postgresql.org/users-lounge/docs/7.2/postgres/functions-datetime.html select '2002-2-2'::date + '100sec'::interval; ?column? ------------------------ 2002-02-02 00:01:40-05 (1 row) If you *must* have a function, try: CREATE FUNCTION "sec2date" (date, interval) RETURNS timestamp AS 'select $1 + $2' LANGUAGE 'SQL'; select sec2date('2002-2-2','100sec'); sec2date ------------------------ 2002-02-02 00:01:40-05 (1 row) At 08:16 AM 2/25/02 -0800, panjas51 wrote: >I tried to make a PLSQL (oracle) function in order to add some seconds >to a specified date: > >Let's take a exemple: >New_date=sec2date(#2002-02-02#, 100), >this should add 100 seconds to the entered date: >this should then return "2002-02-02 00:01:40". > >Attention to the lead year. > >If any one wants to take this challage or propose some quick wins >idees