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: Insert Time only in field DATE

Re: Insert Time only in field DATE

From: Waleed Harbi <waleed.harbi_at_gmail.com>
Date: Sat, 21 Jul 2007 07:41:36 -0000
Message-ID: <1185003696.497117.81430@m3g2000hsh.googlegroups.com>


On Jul 21, 9:21 am, "Michel Cadot" <micadot{at}altern{dot}org> wrote:
> "??Waleed Harbi" <waleed.ha..._at_gmail.com> a écrit dans le message de news: 1184996260.768064.29..._at_w3g2000hsg.googlegroups.com...
> | Hello All,
> |
> | I am trying insert time only in field with data type DATE, but it does
> | not work with me as i want and this is what i did as example:
> |
> | insert into my_table (my_col_date) values
> | (to_date('12:00:00','hh:mi:ss'));
> |
> | When i did this statement oracle save the date for the system without
> | time.
> |
> |
> | What is the solution to insert time alone in oracle field?
>
> SQL> create table t (col date);
>
> Table created.
>
> SQL> insert into t values (to_date('12:00:00','hh:mi:ss'));
>
> 1 row created.
>
> SQL> select to_char(col,'hh:mi:ss') from t;
> TO_CHAR(
> --------
> 12:00:00
>
> 1 row selected.
>
> But what is the meaning of an hour without a day?
>
> | Do you have another data type for time?
> | How I can calculate or compare two field of time? i.e 12:00 + 12:30 OR
> | 12:30 - 12:30
>
> Adding/Subtracting 2 dates is meaningless,
> you likely want to add/subtract 1 date and 1 interval
> or 2 intervals.
> In this case use INTERVAL datatype.
>
> SQL> select interval '12:30' hour to minute from dual;
> INTERVAL'12:30'HOURTOMINUTE
> ---------------------------------------------------------------------------
> +00 12:30:00
>
> 1 row selected.
>
> SQL> select interval '12:30' hour to minute + interval '12:00' hour to minute from dual;
> INTERVAL'12:30'HOURTOMINUTE+INTERVAL'12:00'HOURTOMINUTE
> ---------------------------------------------------------------------------
> +000000001 00:30:00.000000000
>
> 1 row selected.
>
> Regards
> Michel Cadot

Thanks Michel...

when you did SQL> insert into t values
(to_date('12:00:00','hh:mi:ss')); it saved date with time try select * from t;

you will find date & time in same field. Thanks again Received on Sat Jul 21 2007 - 02:41:36 CDT

Original text of this message

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