If you ever need to find the next weekday from a given date in Oracle it turns out they have a built in function for doing just that. If you want the next Sunday from yesterday you would do:
[code lang=”sql”]
SELECT NEXT_DAY(SYSDATE – 1, ‘SUN’) FROM dual;
[/code]
Valid entries for the day are: SUN, MON, TUE, WED, THU, FRI, and SAT
[tags]Oracle, SQL[/tags]
Which version is it? In Version 9 this returns exactly the date next SUNDAY will be. Not next weekday. By the way, the valid entries are sometimes not in english. I have an installation where only Russian abbreviations work.
I did my test in 10g. To be clear, this returns the next day of the week with the given name. If you want the day name of tomorrow you should try: SELECT to_char(sysdate + 1, ‘DY’) FROM dual;