pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Frank Bax <fbax@sympatico.ca>
To: panjas51@yahoo.fr
Cc: pgsql-sql@postgresql.org
Subject: Re: [CHALLANGE] Add seconds to a date
Date: Tue, 26 Feb 2002 14:38:34 -0500
Message-ID: <3.0.6.32.20020226143834.007be200@pop6.sympatico.ca> (raw)
In-Reply-To: <3c1b889f.0202250816.298b7afd@posting.google.com>

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



view thread (2+ messages)

Message-ID: <3.0.6.32.20020226143834.007be200@pop6.sympatico.ca>
Permalink:  ../3.0.6.32.20020226143834.007be200@pop6.sympatico.ca/
Also on:    postgresql.org/message-id/3.0.6.32.20020226143834.007be200@pop6.sympatico.ca

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: fbax@sympatico.ca, panjas51@yahoo.fr
  Subject: Re: [CHALLANGE] Add seconds to a date
  In-Reply-To: <3.0.6.32.20020226143834.007be200@pop6.sympatico.ca>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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