I have the following validation:
DATE1 + INTERVAL to_char(DATE2, 'HH24:MI:SS') HOUR TO SECOND > DATE3;
But it keeps me saying that the operator is not valid. What am I doing wrong?
It looks like you're trying to get the time part from DATE2
and add it to DATE1
? I'm afraid that Oracle doesn't recognize TO_CHAR(date2...)
as an INTERVAL
literal even though it appears to be in the correct format. I would try this instead (good old-fashioned Oracle date arithmetic):
date1 + ( date2 - TRUNC(date2) ) > date3;
You could also do the following:
date1 + TO_DSINTERVAL('0 ' || TO_CHAR(date2, 'HH24:MI:SS')) > date3;
where date2
is converted to a DAY TO SECOND
INTERVAL
(I'm using 0
for the number of days since you want only the time part).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.