Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old May 12th, 2004, 12:58 PM
MooMoo MooMoo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 MooMoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
TIME type in Oracle (newbie)

Hi, I'm a newbie to Oracle DB. I'm wondering, how to store time in an Oracle DB. I found only DATETIME type, that stores date and time together in only one field. But how to store the time only, if I want to search by this field. Is there any way, how to set the date part of the DATETIME or is there any usuall well-known solution to this issue?

Thanx
MooMoo

Reply With Quote
  #2  
Old May 13th, 2004, 12:58 AM
dhananjayshetty dhananjayshetty is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 24 dhananjayshetty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 33 m 16 sec
Reputation Power: 0
Hi,

if you want to insert time then use this:


insert into tablename values(to_char(sysdate,'hh:mi:ss'))
/

Last edited by dhananjayshetty : May 13th, 2004 at 01:04 AM.

Reply With Quote
  #3  
Old May 13th, 2004, 04:45 AM
MooMoo MooMoo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 MooMoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by dhananjayshetty
Hi,

if you want to insert time then use this:


insert into tablename values(to_char(sysdate,'hh:mi:ss'))
/


Hi,

what I need is to insert the time provided by myself and to search the table using time only. If I use DATETIME to store the time, there's also a date part, that is also compared. But I need to search only by the time part of the DATETIME.
Did you mean, that I should store the time as a CHAR field???

MooMoo

Reply With Quote
  #4  
Old May 13th, 2004, 01:32 PM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
No, don't use char datatype for timestamp, TIMESTAMP or DATE datatype can be used, but to match the timestamp only, you need to specify timestamp part, an example is given below:
SELECT empno, ename, to_char(hiredate,'DD-MON-YYYY HH24:MI:SS') FROM emp
WHERE to_char(hiredate,'HH24:MI:SS') between to_char(to_date(hiredate,'HH24:MI:SS),'HH24:MI:SS') AND to_char(to_date('16:00:00','HH24:MI:SS'),'HH24:MI:SS')

Note: Be careful updating timestamp part of any DATE column because the date part is automatically set to the current system date if no date is provided by the user.
/

Reply With Quote
  #5  
Old May 16th, 2004, 06:42 AM
bergner bergner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 144 bergner User rank is Private First Class (20 - 50 Reputation Level)bergner User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 7 h 48 m 6 sec
Reputation Power: 5
Or you can use a simple number

A number that counts the number of seconds since midnight, or milliseconds if you require better precision. Often easier to work with than constantly needing to use to_char and to_date.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > TIME type in Oracle (newbie)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway