Jorge
Jorge

Reputation: 2239

DATE CONVERSION IN SQL DEVELOPER RETURNS AN ERROR

I have this code:

DEFINE value1 = '20-JUL-20';

SELECT to_DATE(&&value1, 'DD-MON-YY') from dual;

But returns this error:

ORA-00904: "JUL": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:
Error at Line: 17 Column: 19

It seems it is having problem converting the string to date. I am wondering if you guys can explain why and if there is a fix to it. Thanks.

Upvotes: 0

Views: 148

Answers (1)

GMB
GMB

Reputation: 222542

You need single quotes around the substitution variable:

DEFINE value1 = '20-JUL-20';
SELECT to_DATE('&&value1', 'DD-MON-YY') from dual;

Upvotes: 3

Related Questions