Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get previous year-month?

Mark1970Mar 5 2015 — edited Mar 5 2015

Hi,

I have to get the previous three year-month of actual date but I have a problem for the beginning of the year and this is because I define the erroneus query.

I mean:

I've written this query

SELECT TO_CHAR(SYSDATE,'YYYYMM')-1, TO_CHAR(SYSDATE,'YYYYMM')-2, TO_CHAR(SYSDATE,'YYYYMM')-3

FROM DUAL;

in order to get (on March):

201502, 201501, 201412

but unfortunately I get:

201502, 201501, 201500

Can you help me?

Thanks in advance!

This post has been answered by Frank Kulash on Mar 5 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 2 2015
Added on Mar 5 2015
4 comments
19,339 views