I would like to insert data to db as time, not date. If I use to_date('2012-08-31 07:39:33', 'YYYY-MM-DD HH24:MI:SS') it adds date too.
If I use to_date('09:34:00', 'HH24:MI:SS') it adds year, month, day as well, from nowhere 😐
Later I need to get rows where time is between x and y, not taking in account the year, month or day. How do I do that?
thanks
I would like to insert data to db as time, not date. If I
Share
A
DATEtype always includes the date component.One option is to continue using
DATEand write your code to ignore the date component. In order to make queries on the time efficient, you might want to create a function-based index on something likeTO_CHAR( date_field, 'HH24:MI:SS' )and use that expression in your queries.Alternatively, you could use a
NUMBERfield to store the number of seconds since midnight, and write your queries in terms of that.