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!

To_Date Using SysDate

Don_WilsonJun 1 2015 — edited Jun 1 2015

Hi Group,

In need to have my report bring back date from 2 date ranges:

From January 1 of this year to Today's date minus 1 day AND

From January 1 of LAST YEAR to (Today's Date - 1 day) - 12 months

I've written my SQL code as:

and a19.FULL_DATE between To_Date((SELECT TRUNC(SysDate,'YEAR') From Dual)) and To_Date((Select SysDate - 1 from Dual))

and a19.FULL_DATE between To_Date((SELECT ADD_MONTHS(TRUNC(SysDate,'YEAR'),-12) From Dual)) and To_Date((add_months(SysDate - 1), -12))

The first line appears to run correctly.  However I'm getting an error on the second line.  It is saying that I have a "invalid number of arguments).  The "add_months" (on the second "To_Date" statement) is highlighted.  Clearly I have some kind of syntax error.  Can someone recommend the correct way to write this?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 29 2015
Added on Jun 1 2015
6 comments
2,626 views