Link to home
Start Free TrialLog in
Avatar of FutureDBA-
FutureDBA-

asked on

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
Avatar of chaau
chaau
Flag of Australia image

You do not need to use to_char:

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

Open in new window

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
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

Avatar of FutureDBA-
FutureDBA-

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial