Make TIMESTAMP + TIME in the source code

Поиск
Список
Период
Сортировка
Искать

Make TIMESTAMP + TIME in the source code

От:
"Luis D. García" <ldgarc@gmail.com>
Дата:
Hello, I'm writinng again because I need to make some validation for
the incoming data (VALUES... on the INSERT-Stmt). This validation
is based on adding a TIMESTAMP and a TIME kind of data.

From the Shell I can make:

template1=# select timestamp '02/03/85 7:00pm'+'00:00:02.3450' as "TIMESTAMP+TIME";

And that would give me the next result:
    
   TIMESTAMP+TIME

      -------------------------
 1985-02-03 19:00:02.345

That's exactly wath I need to do, obtain the result from adding a TIMESTAMP
and a TIME, but I must do it from the Postgre's source code, since I'm working
on modifying Postgres for a University Project (here in Venezuela we call it
"Tesis" or "Graduation Special Work".

Due to this, I need to know if there's a special function on Postgre's backend
code that can do this.

Greetings, I hope you could help me on this.

PD: in adition, both data (TIMESTAMP and TIME) are stored in strings (char *).
The TIME is stored on the pg_class structure (thanks to a modification I made),
and the TIMESTAMP is given on the INSERT values.
--
Luis D. García M.

Telf: (+58) 2418662663
Cel.: (+58) 4143482018

- FACYT - UC -
- Computación -

Re: Make TIMESTAMP + TIME in the source code

От:
Martijn van Oosterhout <kleptog@svana.org>
Дата:
On Mon, Mar 19, 2007 at 06:16:57PM -0400, Luis D. García wrote:
> Hello, I'm writinng again because I need to make some validation for
> the incoming data (VALUES... on the INSERT-Stmt). This validation
> is based on adding a TIMESTAMP and a TIME kind of data.
> 
> >From the Shell I can make:
> 
> template1=# select timestamp '02/03/85 7:00pm'+'00:00:02.3450' as
> "TIMESTAMP+TIME";

You're confused. You're not adding TIME, you're adding an INTERVAL,
which is something quite different.

> That's exactly wath I need to do, obtain the result from adding a TIMESTAMP
> and a TIME, but I must do it from the Postgre's source code, since I'm
> working
> on modifying Postgres for a University Project (here in Venezuela we call it
> "Tesis" or "Graduation Special Work".

Well, any function you can call from SQL you can call from C, see the
OidFunctionCall functions.

> PD: in adition, both data (TIMESTAMP and TIME) are stored in strings (char
> *).

Err, why, when there are perfectly good datatypes to store that type of
data.

Have a nice day,
-- 
Martijn van Oosterhout      http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.
FAQ