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: SQL: How to select date by month and/or year

Re: SQL: How to select date by month and/or year

From: Larry Jones <lljo_at_chevron.com>
Date: 1997/05/07
Message-ID: <3370D5A0.3BC8@chevron.com>#1/1

raab_at_amsd3c.imib.rwth-aachen.de wrote:
>
> Hello,
>
> how can I perform a selection of a date-field by any single subfield (day, month, year ...). I tried
>
> select * from test_table where date_field like to_date('01', 'MM')
>
> and some other combinations without success (i.e. "0 rows selected").
>
> I checked the FAQs but didn't find helpful information.
>
> Thanks ind advance.
>
> Friedhelm Raab raab_at_amsd3c.imib.rwth-aachen.de

Not sure if this is what you meant, but this should work. It will depend on your date format, of course, but using our default date format (dd-mon-yy) this worked for me.

select * from test_table where to_char(date_field) like '%JAN%';

        returns all January dates

select * from test_table where to_char(date_field) like '01%';

        returns all dates beginning with 01

Hope this helps. Sorry if I mis-understood. Received on Wed May 07 1997 - 00:00:00 CDT

Original text of this message

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