when the following PL/SQL anonymous block is run using SQL DEVELOPER on Oracle DB 11g
SET SERVEROUTPUT ON;
DECLARE
d_next_run_date TIMESTAMP WITH TIME ZONE;
BEGIN
dbms_scheduler.evaluate_calendar_string(
calendar_string => 'FREQ=DAILY;INTERVAL=15',
start_date => TO_TIMESTAMP_TZ('04/06/2021', 'DD/MM/YYYY'),
return_date_after => TO_TIMESTAMP_TZ('01/01/2022', 'DD/MM/YYYY'),
next_run_date => d_next_run_date
);
dbms_output.put_line(d_next_run_date);
END;
the following exception is thrown
ORA-01870: the intervals or datetimes are not mutually comparable
ORA-06512: at "SYS.DBMS_SCHEDULER", line 3599
ORA-06512: at line 4
01870. 00000 - "the intervals or datetimes are not mutually comparable"
*Cause: The intervals or datetimes are not mutually comparable.
*Action: Specify a pair of intervals or datetimes that are mutually
comparable.
I suspect the issue is related to timezone.
The exception is not thrown if the arguments are changed to the following (notice that I changed the value that is passed into parameter return_date_after)
SET SERVEROUTPUT ON;
DECLARE
d_next_run_date TIMESTAMP WITH TIME ZONE;
BEGIN
dbms_scheduler.evaluate_calendar_string(
calendar_string => 'FREQ=DAILY;INTERVAL=15',
start_date => TO_TIMESTAMP_TZ('04/06/2021', 'DD/MM/YYYY'),
return_date_after => TO_TIMESTAMP_TZ('01/01/2021', 'DD/MM/YYYY'),
next_run_date => d_next_run_date
);
dbms_output.put_line(d_next_run_date);
END;
or if the arguments are changed to the following (again I changed the value that is passed into parameter return_date_after)
SET SERVEROUTPUT ON;
DECLARE
d_next_run_date TIMESTAMP WITH TIME ZONE;
BEGIN
dbms_scheduler.evaluate_calendar_string(
calendar_string => 'FREQ=DAILY;INTERVAL=15',
start_date => TO_TIMESTAMP_TZ('04/06/2021', 'DD/MM/YYYY'),
return_date_after => TO_TIMESTAMP_TZ('01/06/2022', 'DD/MM/YYYY'),
next_run_date => d_next_run_date
);
dbms_output.put_line(d_next_run_date);
END;
The requirements that I have to fullfill need not support timezone. If possible, I would like to use datatype DATE with procedure dbms_scheduler.evaluate_calendar_string. However, dbms_scheduler.evaluate_calendar_string parameters are of type TIMESTAMP WITH TIMEZONE. How could I convert from DATE into TIMESTAMP WITH TIMEZONE and avoid that exception?
I noticed that the exception is thrown when a date value that corresponds to summer is passed into parameter return_date_after. So the error might be related to daylight saving time.
database version: 11.2.0.1.0