0

I'm using Oracle and there is no time data type. Is there a reason for this?

Also, what are ways I can simulate the time data type that is provided by other DB's like MySQL and SQLServer.

Brian T Hannan
  • 3,925
  • 18
  • 56
  • 96
  • Oracle's original developers would probably having to supply a reason, anything else is speculation. What do you want to do with the type, and how do you want to restrict it? What use is a time without a date - do you want to record an elapsed time, for example? Hopefully you are not trying to split a datetime into two columns. – Alex Poole Jun 12 '15 at 23:11
  • 1
    Some ideas [here](http://stackoverflow.com/q/12215281/266304) and [here](http://stackoverflow.com/q/1786418/266304), depending on what you really need. – Alex Poole Jun 12 '15 at 23:24
  • If you're collecting data where the day is irrelevant but the time of day matters. Most other DBs have a time data type but Oracle doesn't and I found that to be weird. – Brian T Hannan Jun 13 '15 at 04:54
  • OK, but 'why' is going to be off-topic, and 'how' is probably a duplicate but depends what you need to do with the value. You can store seconds, time on an arbitrary date, interval, even a string (but usually a bad idea!); which is right for you depends on what manipulation or comparison you need to do. – Alex Poole Jun 13 '15 at 12:24
  • 1
    use the DATE data type - supply a time w/o the date, it will be stored as the first day of that month with your time. you can query the time only via extract() function or set your date format to be time only to work with your times – thatjeffsmith Jun 13 '15 at 12:43

0 Answers0