sql - Oracle next_day function returns wrong date -
i running oracle database 11g express edition. when issue:
select next_day('04-jun-15', 'friday') dual;
i getting correct result '05-jun-15'.
when issuing:
select next_day(date '15-06-04', 'friday') dual;
i getting pretty strange result '07-jun-15'.
@ same time both dates looks same me:
select to_char(date '15-06-04', 'dd-mm-rr hh24:mi:ss'), to_char(to_date('04-jun-15'), 'dd-mm-rr hh24:mi:ss') dual;
both return '04-06-15 00:00:00'.
can explain why works in way?
thanks!
next_day(date '15-06-04', 'friday')
you reinvented y2k bug. year should yyyy format in complete 4 digits. or, use rr format along to_date. there rules rr format need take care.
the ansi date literal contains no time portion, , must specified in format ('yyyy-mm-dd').
make correction , correct result:
ansi date literal
sql> select next_day(date '2015-06-04', 'friday') dual; next_day( --------- 05-jun-15 sql>
to_date rr format
sql> select next_day(to_date('15-06-04', 'rr-mm-dd'), 'friday') dual; next_day( --------- 05-jun-15 sql>
Comments
Post a Comment