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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Check if given date is past date of a given month

3751736Jul 28 2018 — edited Aug 2 2018

Hello;

I have date coming in as character datatype. I have requirement that

need to check if given date is past date of a given month then set the date as the last day in the month.

I know how to set for the last date of the month by using last_day function. But I want to know how can I check if the give date value falls in the specific month or out and I think I need to check with year value too for leap year on February last day.

SELECT  CASE WHEN to_char(trunc (LAST_DAY(SYSDATE))) <  '20180841' THEN LAST_DAY(sysdate) else01’ end from dual;

I used above SQL and I am getting this issue

ORA-00932: inconsistent datatypes: expected DATE got CHAR

I know the issue but want to make sure with the team.

Thank you for your Time and advice.

This post has been answered by Paulzip on Jul 29 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 30 2018
Added on Jul 28 2018
12 comments
2,054 views