Skip to Main Content

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 due to inactivity on Aug 30 2018
Added on Jul 28 2018
12 comments
942 views