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: query on date

Re: query on date

From: Pierre Charpenay <pcharpenay_at_unilog.fr>
Date: Fri, 31 Mar 2000 14:07:13 +0200
Message-ID: <38E494F1.FF36BD0D@unilog.fr>

simon cunningham a écrit :
>
> Hi
>
> I have a table with the date_of_death as a column dd-mm-yy.
> Now I wan to run a select statement from this column, where the clause
> is on the year,
>
> So
> select *
> from patient
> where (trunc ('date_of_death', 'YY') = '94'

Use to_char (conversion of a date into string according the given format, in this cas, the 2 last number of the year) instead of trunc (truncation of a date according a format, in this case 'Y' gives with evry date in year 1994, '01-Jan-1994' !)

> //where YY is year
> Is this the corect way to run this query
>
> Thanks everyone

This will be OK only if your 'date_of_death' column is of type DATE (if it is CHAR or VARCHAR2, simply use substr() ).

Bye

--
 Pierre CHARPENAY Received on Fri Mar 31 2000 - 06:07:13 CST

Original text of this message

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