Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How To Extract Hour From A Date Column In A Table?

Re: How To Extract Hour From A Date Column In A Table?

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 5 Apr 2006 16:58:55 -0700
Message-ID: <1144281535.609658.206430@t31g2000cwb.googlegroups.com>


The extract function can only be used to extract the Year, Month, and Day from a date data type. For hours, minutes, and seconds you would have to convert the date data type to a timestamp first. Being that you could just use to_char on the date data type, as previously pointed out, to get the same information more efficiently why would you do to the trouble?

select
  current_timestamp CT
,to_char(sysdate,'YYYYMMDD HH24:MI:SS') CD
,extract(hour from to_timestamp(

    to_char(sysdate,'DD-MON-YY HH24.MI.SS'))) as Hour
,extract(minute from to_timestamp(

    to_char(sysdate,'DD-MON-YY HH24.MI.SS'))) as Minute
,extract(second from to_timestamp(

    to_char(sysdate,'DD-MON-YY HH24.MI.SS'))) as Seconds from sys.dual
/

HTH -- Mark D Powell -- Received on Wed Apr 05 2006 - 18:58:55 CDT

Original text of this message

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