Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to convert Oracle Database Date Type to C time_t

Re: How to convert Oracle Database Date Type to C time_t

From: Michel Cadot <micadot_at_francemel.com>
Date: Thu, 19 Aug 1999 14:28:36 +0200
Message-ID: <7pgtam$dqa$1@oceanite.cybercable.fr>


Ellen,

I think you're wrong with operations on date type. Your select can be (t as long):
select
to_number( to_char(datecol,'J'))*24*60*60+to_number(to_char(datecol,'SSSSS')) -

          (to_number(to_char(to_date('01/01/1970','DD/MM/YYYY'),'J'))*24*60*60
           +to_number(to_char(to_date('01/01/1970','DD/MM/YYYY'),'SSSSS')) )
into :t
from ...;

This gives you the number of seconds since 01/01/1970. Has time_t type a particuliar structure?

ellen111_at_my-deja.com a écrit dans le message <7pgnl5$kgj$1_at_nnrp1.deja.com>...
>Hi, when I try to retrieve date from oracle database, and convert it
>to time_t type, I have some questions.
>
>the way now I used is:
>select date into char from oracle database, then convert char
>to time_t(I wrote a function by myself). and it is not very efficient.
>
>I was told that there is a way to convert them directly:
>select date into time_t(? or long, because there is no time_t date
>type in pro*C), following is my code:
>
>EXEC SQL BEGIN DECLARE SECTION;
>time_t t; //this got an error when precompile
>long t; //?
>EXEC SQL END DECLARE SECTION;
>....
>EXEC SQL SELECT ((new_time(date,'EST','GMT') -
> to_date('01-jan-1970','dd-mon-yyyy'))*24*60*60)
> INTO :t
> FROM .....
>printf("time=%d\n",t);
>
>but it returns 0 to me...
>any advises please!
>
>Ellen
>
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
Received on Thu Aug 19 1999 - 07:28:36 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US