Re: HELP! Date functions make my brain hurt!

From: Randy <rmramos.gbs_at_worldnet.att.net>
Date: 1996/08/17
Message-ID: <4v3c1b$bvu_at_mtinsc01-mgt.ops.worldnet.att.net>#1/1


rxrgroup_at_earthlink.net (Mike Stenzler) wrote:
>I'm trying to retrieve a range of dates from a table.
>
>I'm wrinting in Visual C++ & accesing the db thru DTK++ - a class
>library marketed by Intersolv that puts a thin wrapper around ODBC
>
>the ? char is the replacement metachar for binding parameters &
>retrieval values
>
>Essentailly I want to do somthing like this:
>
>int GetDates(char *event, char dates[][DATE_SIZE], char *s, char *e)
>{
> char evdate[DATE_SIZE];
> int i = 0;
>
> // do DTK initialization stuff here
>
> // bind query parameters here - simplified
> SetParam(1, event); // event param
> SetParam(2, s); // starting date
> SetParam(3, e); // ending date
>
> // bind result here
> Bind(1, evdate);
>
> // my select - w/o DTK stuff
> select ev_date
> from event_dates
> where event = ? // 1st param - the event
> and ev_date >= ? // 2nd param - the starting date
> and ev_date <= ? // 3rd param - the ending date
> order by ev_date;
>
> // fetch repeatedly until no more rows
> for(qry->fetchfirst(); qry->sqlsuccess(); qry->fetchnext, i++)
> {
> strcpy(evdates[i], evdate);
> }
>
> return(i);
>}
>there is no problem with the fetching logic, etc. My problem is in
>how to use the date functions provided by Oracle to convert my
>values to Julian so I can do a compare in my where clause.
>
>I've tried: and ev_date >= to_date(?, 'J')
>
>can anyone help?
>
>my parameters are char strings of the format 'MM-DD-YY'
>I usually retrieve dates from the DB using:
> to_char(ev_date, 'MM-DD-YY')
>
>I'd appreciate any clues.
>
>TIA - mike
>
>
>Mike..The only thing I can add is try this:

  1. create an (assignment) variable (i.e. X)
  2. do ... X = to_date(?, 'J')
  3. your logic ... and ev_date >= X

even if this does not work ....what the heck is in X

Hope This Helps
R2
rmramos.gbs_at_worldnet.att.net
Independent Oracle Consultant
>
>
>
Received on Sat Aug 17 1996 - 00:00:00 CEST

Original text of this message