Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need to displays the previous ye

Status
Not open for further replies.

vani65

Programmer
May 19, 2003
101
0
0
AU
I need to displays the previous year in character format.
SELECT
TO_CHAR(TO_NUMBER(SYSDATE,'yyyy')-1),'YYYY')
FROM
dual

i'm trying to subtract 1 from a character string,I get an error msg stating
"FROM keyword not found where expected".

Please advice...thank you.

 
Vani,

You have two open parens and three close parens, which probably caused the "FROM" error. Here's what I get with a similar query:

select to_char(trunc(sysdate,'yyyy')-1,'yyyy') from dual;

TO_C
----
2002

1 row selected.
 

SELECT TO_NUMBER(TO_CHAR(SYSDATE,'YYYY'),'9999')-1 FROM dual;

-Sudhí
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top