Home » RDBMS Server » Server Administration » problem with date
problem with date [message #127287] Mon, 11 July 2005 01:41 Go to next message
raghuraja_r
Messages: 22
Registered: February 2005
Location: chennai
Junior Member

hi everybody

create table t(d date);

insert into t values(to_date('09-05-2005 4:16:46 PM', 'dd-MM-yyyy HH:MI:SS AM'));

select * from t;

d
----------
09-may-05


the problem is
how should i get time using the select stmt.

and also is there is any way to keep track of the time values in a column
or is it possible to enter only time in Date type column;


Re: problem with date [message #127289 is a reply to message #127287] Mon, 11 July 2005 01:46 Go to previous messageGo to next message
somnath1974
Messages: 15
Registered: July 2005
Junior Member
Hi,
Check the NLS_DATE_FORMAT value in the NLS_DATABASE_PARAMETERS table. I think is it is set to dd-mon-rr. You need to modify it to be able to see the time part.

For example:
ALTER SESSION SET NLS_DATE_FORMAT='YYYYMMDDHH24MISS' ;

to be able to see the time part. The time part is inherently stored along with the date field in case you feed the time.

HTH

Somnath
Re: problem with date [message #127291 is a reply to message #127287] Mon, 11 July 2005 01:57 Go to previous messageGo to next message
raghuraja_r
Messages: 22
Registered: February 2005
Location: chennai
Junior Member

hi somnath

thanks for your rapid reply

i just altered as u said

then it displays as

d
--------------
20050509161045

ho to get good format.
and what about my remaining doubts for time field

thanks
Re: problem with date [message #127306 is a reply to message #127291] Mon, 11 July 2005 03:19 Go to previous messageGo to next message
girish.rohini
Messages: 744
Registered: April 2005
Location: Delhi (India)
Senior Member
HI

U can view the selected date in any format that u specify in ur query.
For eg:
select to_char(d,'dd-MM-YYYY HH24:MI:SS') from t;

Also u can set the NLS_DATE_FORMAT parameter specifying the format that u wish to view.
Eg:
ALTER SESSION SET NLS_DATE_FORMAT='DD-MM-YYYY HH24:MI:SS' ;

Date is stored in data field in format defined by NLS. This includes the time as well.

Regds
Girish


Re: problem with date [message #127354 is a reply to message #127287] Mon, 11 July 2005 06:13 Go to previous messageGo to next message
raghuraja_r
Messages: 22
Registered: February 2005
Location: chennai
Junior Member

hi somnath

thanks thanks thanks a lot.
its working fine and i can able to retrive time alone.
but consider my other question for a time field without date.

regards
raghu r
Re: problem with date [message #127409 is a reply to message #127287] Mon, 11 July 2005 10:04 Go to previous messageGo to next message
smartin
Messages: 1803
Registered: March 2005
Location: Jacksonville, Florida
Senior Member
Why do you need the time without the date?

But, check into the application developers guide fundamentals, chapter 2.

file:///E:/Scot/Oracle%2010gR1%20Doc%20Library/B14117_01/B14117_01/appdev.101/b10795/adfns_ty.htm#1006171
Re: problem with date [message #127413 is a reply to message #127287] Mon, 11 July 2005 10:13 Go to previous messageGo to next message
raghuraja_r
Messages: 22
Registered: February 2005
Location: chennai
Junior Member

hi all

one of the developer needs to keep track of the time in his application
or some check-in/check-out time to be maintained thats y i m asking for a field to keep track of time alone.
Re: problem with date [message #127414 is a reply to message #127287] Mon, 11 July 2005 10:16 Go to previous message
smartin
Messages: 1803
Registered: March 2005
Location: Jacksonville, Florida
Senior Member
You don't have to use or display the date if you only are interested in the time. But both will be stored in the date field (and the timestampt field as well I believe). So just ignore the presence of the date, only use the time.

MYDBA@ORCL > select to_char(sysdate,'HH24:MI:SS') from dual;

TO_CHAR(
--------
11:19:22

Previous Topic: free space from temp tablespace oracle 8i
Next Topic: system tablespace
Goto Forum:
  


Current Time: Fri Jan 10 07:21:41 CST 2025