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

Home -> Community -> Usenet -> c.d.o.tools -> Re: How do you pass C time_t datetime to Oracle?

Re: How do you pass C time_t datetime to Oracle?

From: Mark D Powell <markp7832_at_my-deja.com>
Date: 2000/05/01
Message-ID: <8ek3lb$4vf$1@nnrp1.deja.com>#1/1

In article <957173205.17324.0.pluto.d4ee154e_at_news.demon.nl>,   "Sybrand Bakker" <postbus_at_sybrandb.demon.nl> wrote:
> date columns are treated a strings in C.
>
> Hth,
>
> Sybrand Bakker, Oracle DBA
>
> Don Chambers <dchamber_at_mindspring.com> schreef in berichtnieuws
> ikqpgs8m3pcqp0lmr91cihte57tv1pb9sn_at_4ax.com...
> > I am writing my first C++ UNIX program that uses an Oracle database.
> > I am writing the middle tier componet and am having trouble with
> > datetime values.
> > .
> > I will be passed a time_t and must return a time time_t. I am not
> > able to get the time_t into the database as a DATE or select a
> > date/time and covert it to the time_t.
> >
> > Can I insert this format into Oracle directly? I could not find
 this
> > format for the TO_DATE function.
> >
> > How do you handle this?
> >
> > I have written a couple functions to do the conversions using a
> > variety of methods and seem to be off because of time zones. I
 would
> > think that this is a common task and should be relativly easy.
> >
> > This time_t variable comes from a windows system where the time is
> > actually an unsigned long that is the number of seconds from Jan. 1,
> > 1970 00:00:00. In the middle tier I am using Pro*C/C++. Does pro C
> > provide a conversion for this?
> >
> >
> > Thanks,
> > Don
> > chambers_at_inquiregroup.com
> >
>

I can not guarentee this is correct since I do not write C, but I gave this to someone once before who was using a reference date and they responded that it worked for them:
rem
rem Convert Oracle date to number of seconds since reference date rem
rem 20000412 Mark D Powell New
rem
select to_number(sysdate - to_date('01-JAN-1970','DD-MON-YYYY'))

If you run the above the second sql will convert the value returned by the first sql back to the current date/time so it looks like it works, but I am not a date/time expert.

--
Mark D. Powell  -- The only advice that counts is the advice that
 you follow so follow your own advice --


Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Mon May 01 2000 - 00:00:00 CDT

Original text of this message

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