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: WildCards to match Date

Re: WildCards to match Date

From: Mark D Powell <markp7832_at_my-deja.com>
Date: Tue, 26 Sep 2000 14:13:17 GMT
Message-ID: <8qqat9$k46$1@nnrp1.deja.com>

In article <39CFE818.3E507316_at_glue.umd.edu>,   liming <lmxu_at_glue.umd.edu> wrote:
> hi, I'm trying to match a date in my database with wildcards in the
> format of DD-MM-YYYY...for example, *-12-1998 should match with any
> dates of Dec in 1998.... .A gentleman called Steve pointed out some of
> my syntax error this afternoon......thanks Steve... I'm a newbie and
> just got started....thanks guys..
>
> I'm using Pro C...
>
> here is what I have in the program
>
> EXEC SQL declare curdob cursor for
> select dob,name from Contacts where
> to_date(dob,'DD-MM-YYYY') like to_date(:tdob,'DD-MM-YYYY') ORDER BY
> to_date(dob,'DD-MM-YYYY'),name;
> EXEC SQL open curdob;
> EXEC SQL fetch curdob into :cmatchdob,:cmatchname;
>
> But when I tested if the above operated correctly or not, using
> (sqlca.sqlcode<0) , it always tell me it's <0 which means
> that the above code was not excute correctly....what was wrong?????
> Thank you..
>
> Variable Descriptions:
> dob: date column name in the table (varchar)
> name: name column in the table. (varchar)
> :tdob: the string date I read from the input... (Varch
> :cmatchdob: a string to store date.....(Varchar)
>
> Thanks.
>

1) Date columns in the database would not be referrenced in a to_date variable. They would be referenced as is by column name or in a to_char function.

2) The like clause requires a wildcard character, either '%' for any number of characters or '_' for a single character

3) You probably want to code something like:

     where to_char(date_col,'YYYYMM') = '199812'

--
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 Tue Sep 26 2000 - 09:13:17 CDT

Original text of this message

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