Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: extracing the hour from a date
The function you want to use is to_char, not trunc.
Ken Denny
laredotornado_at_zipmail.com wrote:
> Hello,
> I am using Oracle 8.1.7 to try and extract hours from dates. I
want
> to write a SELECT statement to return only the 2-digit hour from a
> date. But i'm having little success. If I try ...
>
> select trunc(sysdate, 'HH24') from dual
>
> I get
>
> 2005-03-25 12:00:00.0
>
> but when I try
>
> select to_char(trunc(sysdate, 'HH24')) from dual
>
> I get
>
> 25-MAR-05
>
> making it impossible for me to use SUBSTR to extract the 2-digit
hour.
> Are there other functions that I should be using?
>
> Thanks, -
Received on Fri Mar 25 2005 - 12:01:40 CST
![]() |
![]() |