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: extracing the hour from a date

Re: extracing the hour from a date

From: <ken_at_kendenny.com>
Date: 25 Mar 2005 10:01:40 -0800
Message-ID: <1111771500.225203.298750@f14g2000cwb.googlegroups.com>


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

Original text of this message

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