Oracle SQL - Determine if a timestamp falls within a range, excluding date -
i'm looking way determine if timestamp falls between 2 times, regardless of date in timestamp. example, if time in timestamp falls between '00:00:00.000' (midnight) , '01:00:00.000' (1 a.m.), i'd want select row regardless of particular date.
i've tried lots of different variations on to_char
, to_date
functions, keep getting errors. coming informix, oracle seems more complicated.
the thing closest "correct" (i think) i've tried is:
select * my_table substr(to_char(my_timestamp), 10) > '00:00:00.000' , substr(to_char(my_timestamp), 10) < '01:00:00.000'
... nothing works. tips or tricks?
i found way it, i'd still prefer little less hacky, if exists.
substr(substr(to_char(my_timestamp), 11), 0, 12) > '01.00.00.000'
your solution looks correct me except haven't tried substr function. used in 1 of previous project:
select * orders to_char(my_timestamp,'hh24:mi:ss.ff3') between '00:00:00.000' , '01:00:00.123';
Comments
Post a Comment