Reputation: 377
Why do I get this error:
Error starting at line 1 in command:
select name,major, lpad(to_char(date_birth,'dd'),10) "Date of birth",
to_char(next_day(date_birth,'sunday'),'dd') - to_char(date_birth,'dd') "Different in days"
from students
SQL Error: ORA-01846: not a valid day of the week 01846. 00000 - "not a valid day of the week"
when I run the following query?
select name,major, lpad(to_char(date_birth,'dd'),10) "date of birth",
to_char(next_day(date_birth,'sunday'),'dd') - to_char(date_birth,'dd') "Different in days" from students
Upvotes: 2
Views: 13513
Reputation: 156
You have to write the name of the days in the language that you have set on sql developer, which is most likely not english. But best practice is to set integers, like @user4507518 said.
Upvotes: 2
Reputation: 71
Try changing next_day(date_birth,'sunday') to next_day(date_birth,1) -- 1 stands for the first day of the week i.e. Sunday
Upvotes: 2