help with next_day

select NEXT_DAY(to_char(to_date(20131003,'yyyymmdd'), 'MON-DD-YY'),'Tuesday') from dual;

Open in new window

isnt working for me. i thought this is how it's supposed to be used. but i'm getting ORA-01858 a non-numeric character was found where a numeric was expected
FutureDBA-Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chaauCommented:
You do not need to use to_char:

select NEXT_DAY(to_date(20131003,'yyyymmdd'),'Tuesday') from dual;

Open in new window

0
HuaMin ChenProblem resolverCommented:
Try
select NEXT_DAY(to_date('20131003','yyyymmdd'),'Tuesday') from dual;

Open in new window


and read
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions093.htm
0
Gerwin Jansen, EE MVETopic Advisor Commented:
Do you want the next 'Tuesday' from the date you are entering? You're entering 20131003, the next Tuesday would be 20131008, is that what you want?

This will get you the next Tuesday in YYYYMMDD format from the given date:
select to_char(next_day(to_date('20131003','YYYYMMDD'),'Tuesday'),'YYYYMMDD') NEXT_TUESDAY from dual;

Open in new window


This will get you the next Tuesday from today (sysdate):
select to_char(next_day(sysdate,'Tuesday'),'YYYYMMDD') NEXT_TUESDAY from dual;

Open in new window

0
FutureDBA-Author Commented:
I am trying to use this within a case statement, when i use it standalone from dual it's fine, but when i u do
CASE WHEN substr(RVCCUSWK1,1,1) = 1 THEN to_char(next_day(sysdate,'Sunday'),'YYYYMMDD') ELSE 0 END AS SUN, 

Open in new window


I get
ORA-00932: inconsistent datatypes: expected CHAR got NUMBER
00932. 00000 -  "inconsistent datatypes: expected %s got %s"
*Cause:    
*Action:
Error at Line: 15 Column: 97

Open in new window

0
Gerwin Jansen, EE MVETopic Advisor Commented:
Try this:
select
  case when SUBSTR('RVCCUSWK1',1,1) = 'R'
  then TO_CHAR(NEXT_DAY(sysdate,'Sunday'),'YYYYMMDD')
  else '0'
  end as SUN
from dual;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.