Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: query on date
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
![]() |
![]() |