Home » SQL & PL/SQL » SQL & PL/SQL » time fromat
time fromat [message #9521] Tue, 18 November 2003 03:35 Go to next message
lok raj
Messages: 14
Registered: September 2003
Junior Member
i have a table

SQL> desc sch;
Name Null? Type
------------------------------- -------- ----
FLTDATE DATE
DAY VARCHAR2(9)
AIRCRAFT VARCHAR2(5)
FTL_NO VARCHAR2(6)
SECTOR VARCHAR2(7)
ETD VARCHAR2(7)
ATD VARCHAR2(7)
ETA VARCHAR2(7)
ATA VARCHAR2(7)
ADT NUMBER(2)
CHD NUMBER(2)
INF NUMBER(2)
FPAX NUMBER(2)
IND NUMBER(2)
RES NUMBER(2)
FOC NUMBER(2)
CN NUMBER(4)
EB NUMBER(4)
BAG NUMBER(4)

i want to store the time format on the col ETD, ATD, ATA.and ETA (hh:mm)

but i am not successed
Re: time fromat [message #9524 is a reply to message #9521] Tue, 18 November 2003 03:52 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Oracle8i (I'm not yet on 9i here so I'll focus on 8i) stores the date AND time information and displays it in his default date format (called NLS_DATE_FORMAT). In your client, you can change it in the registry: HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE and the key is NLS_DATE_FORMAT. Default it is 'DD-MON-YY'. Another possibility is changing the NLS_DATE_FORMAT for the session only.

Look at the example below:
SQL> create table t(name varchar2(25), arrival DATE);

Table created.

SQL> insert into t values('&name',to_Date('&arrival','HH24:MI'));
Enter value for name: Peter
Enter value for arrival: 12:23
old   1: insert into t values('&name',to_Date('&arrival','HH24:MI'))
new   1: insert into t values('Peter',to_Date('12:23','HH24:MI'))

1 row created.

SQL> /
Enter value for name: Frank
Enter value for arrival: 12:55
old   1: insert into t values('&name',to_Date('&arrival','HH24:MI'))
new   1: insert into t values('Frank',to_Date('12:55','HH24:MI'))

1 row created.

SQL> /
Enter value for name: Jenny
Enter value for arrival: 23:58
old   1: insert into t values('&name',to_Date('&arrival','HH24:MI'))
new   1: insert into t values('Jenny',to_Date('23:58','HH24:MI'))

1 row created.

SQL> /
Enter value for name: John
Enter value for arrival: 9:12
old   1: insert into t values('&name',to_Date('&arrival','HH24:MI'))
new   1: insert into t values('John',to_Date('9:12','HH24:MI'))

1 row created.

SQL> Commit;

Commit complete.

SQL> Select * From t;

NAME                      ARRIVAL
------------------------- ---------
Peter                     01-NOV-03
Frank                     01-NOV-03
Jenny                     01-NOV-03
John                      01-NOV-03

SQL> Select Name
  2       , to_char(arrival,'HH24:MI') arrival
  3    From t;

NAME                      ARRIV
------------------------- -----
Peter                     12:23
Frank                     12:55
Jenny                     23:58
John                      09:12

SQL> Alter session set nls_date_format='HH24:MI'
  2  /

Session altered.

SQL> Select * From t;

NAME                      ARRIV
------------------------- -----
Peter                     12:23
Frank                     12:55
Jenny                     23:58
John                      09:12

SQL> 
HTH,
MHE

If not clear, visit docs.oracle.com or tahiti.oracle.com for the oracle documentation. you might need a free subscription for the site though.
Re: time fromat [message #9529 is a reply to message #9521] Tue, 18 November 2003 05:26 Go to previous messageGo to next message
bhavin
Messages: 6
Registered: May 2003
Junior Member
dear friend,
in which oracle version you r working..
if you r working in oracle 9i then there is a datatype called TIMESTAMP USE THIS DATATYPE. OR U CAN USE ALSO
TO_CHAR FUNCTION TO INSERT THE VALUE IN VARCHAR DATATYPE.
Re: time fromat [message #9542 is a reply to message #9529] Tue, 18 November 2003 22:20 Go to previous messageGo to next message
lok raj
Messages: 14
Registered: September 2003
Junior Member
Dear Friend,

I am working in 8i and developer 6
and attempting to insert time format on those col in form level.

thanks
Time format in Forms [message #9543 is a reply to message #9521] Tue, 18 November 2003 23:29 Go to previous message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Now we're getting somewhere: In forms you can define the property Datatype "Time", which might cause you to receive "Unable to INSERT/UPDATE/Perform query...". If you Shift+F1 you can see the real error.

But if you select datatype "Date" you can store time too, since Oracle stores time info in its DATE columns (as explained before). You just need to specify the Format Mask of the "time" items "HH24:MI" or "HH AM:MI" or any other flavor of the time format masks and set the Datatype of the items to "Date".

Are you getting the ORA-00932: inconsistent datatypes?

HTH,
MHE
Previous Topic: Do While Loops
Next Topic: Multi Cross-Tab Query
Goto Forum:
  


Current Time: Fri Apr 19 11:01:18 CDT 2024