To store just Time information in Oracle column [message #327260] |
Sun, 15 June 2008 16:00 |
thamarais
Messages: 2 Registered: June 2008
|
Junior Member |
|
|
Hi All
I am moving data from MS Access to Oracle.
In MS Access, we have Date (Short Date) field stores just time information like 07:00 AM, 12:29 PM etc.
While moving data from MS Access to Oracle (Date datatype), along with time values (07:00 AM, 12:29 PM), some default date also is getting stored.
The target value getting stored currently is 12/31/1899 07:00 AM, 12/31/1899 12:29 PM.
I don't want 12/31/1899, I need just time information. How to achieve this one?
Thanks
|
|
|
|
Re: To store just Time information in Oracle column [message #327281 is a reply to message #327260] |
Sun, 15 June 2008 23:22 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
thamarais wrote on Sun, 15 June 2008 23:00 |
I don't want 12/31/1899, I need just time information. How to achieve this one?
|
Oracle does not know a datatype that stores only times. In Oracle you use the DATE datatype, which always holds both the date- and the time-part of a moment in time.
Like Anacedent said, you can use to_date to store a time-portion in a DATE-type field, and to_char to display it in any form you want (e.g. only the time part).
|
|
|
|
|
|
|
|
|
|
|
|
Re: To store just Time information in Oracle column [message #328023 is a reply to message #327805] |
Wed, 18 June 2008 11:24 |
thamarais
Messages: 2 Registered: June 2008
|
Junior Member |
|
|
Thanks for the replies.
Front end is ASP pages and management is reluctant to do any changes in front end. All they want to do is backend migration and minimal changes in front end.
All they want is to store just Time information in Oracle database. Because currently in MS Access they are storing with datatype (Date - Short date).
I suggested to define column as Varchar2 or Char. Here the issue is - It takes any value like 25:03:00. It should not accept beyond 24 hrs.
I tried to set constraint in varchar2 or char, but not possible.
Any help please.
Thanks
|
|
|
|
Re: To store just Time information in Oracle column [message #328034 is a reply to message #328025] |
Wed, 18 June 2008 12:13 |
ThomasG
Messages: 3211 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
I wonder what actually WOULD be a good solution.
Since I had quite a few annoying problems in an application that stored "season" start/end dates as dates and only used the day/month part and discarded the year and time part in the input and display I would also be weary to use a date field for storage.
(Some version of the frontends inserted 1900/00:00:00, other versions the current year and time, and so on, so it was awkward to work with in custom reports and extensions we made.)
I would probably consider using a number for "seconds since midnight", and add a constraint that only numbers < 24 * 60 * 60 can be entered for storage of a "time only" value.
Of course it would depend on what I needed to actually do with this time information.
[Updated on: Wed, 18 June 2008 12:15] Report message to a moderator
|
|
|