Take the 2-minute tour ×

just like sysdate inserts the current date,

Is there any way to insert only the current time using a sql query.

for example *insert into table_name values(sysdate); *

share|improve this question
Why you'd want to do this, I don't quite understand. Normally, time without a date is meaningless. Furthermore, as there's no "time" data-type you can't store this in a date field, which is what your current insert statement implies. See stackoverflow.com/questions/1786418/… and stackoverflow.com/questions/15045600/… –  Ben Apr 20 '13 at 12:50
add comment

1 Answer

There is no Oracle data type that represents just a hours/minutes/seconds. There is DATE and the various TIMESTAMP types that represents a point in time, including date and time. You don't say why you're trying to store this, but you could store the time as an offset in a NUMBER column, as fractions of a day.

So, if you wanted to find store the time of day that a store opens on Monday, you'd do:

TRUNC( SYSDATE ) + offset
share|improve this answer
Seconds since midnight or an interval datatype is more common as per the linked questions. 1/3 of a day could cause problems... –  Ben Apr 20 '13 at 13:53
Why would seconds since midnight be better than fraction of a day? You wind up always having to do a conversion with your addition. (I agree it's less intuitive.) Intervals are also an option, though I've seen some weird things happen with execution plans and interval math. –  eaolson Apr 20 '13 at 14:03
actually i am designing a website for quiz so i want to show the time spent for the test. that's why i am trying to take difference of time.Is there any other way to do this? plz suggest. –  Harish Kumar Apr 20 '13 at 15:41
In that case, I would store the time taken as a scalar, number of seconds or fraction of a day. You could also store the start and end of the test as a DATE and subtract the two to find the time taken. –  eaolson Apr 20 '13 at 18:01
add comment

Your Answer


