pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[CHALLANGE] Add seconds to a date
2+ messages / 2 participants
[nested] [flat]

* [CHALLANGE] Add seconds to a date
@ 2002-02-25 16:16 panjas51 <panjas51@yahoo.fr>
  2002-02-26 19:38 ` Re: [CHALLANGE] Add seconds to a date Frank Bax <fbax@sympatico.ca>
  0 siblings, 1 reply; 2+ messages in thread

From: panjas51@yahoo.fr @ 2002-02-25 16:16 UTC (permalink / raw)
  To: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [CHALLANGE] Add seconds to a date
  2002-02-25 16:16 [CHALLANGE] Add seconds to a date panjas51 <panjas51@yahoo.fr>
@ 2002-02-26 19:38 ` Frank Bax <fbax@sympatico.ca>
  0 siblings, 0 replies; 2+ messages in thread

From: Frank Bax @ 2002-02-26 19:38 UTC (permalink / raw)
  To: panjas51@yahoo.fr; +Cc: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2002-02-26 19:38 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-02-25 16:16 [CHALLANGE] Add seconds to a date panjas51 <panjas51@yahoo.fr>
2002-02-26 19:38 ` Frank Bax <fbax@sympatico.ca>

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