Suppose i've got a Date column that has the date 31-JUL-2011. Im obtaining the last date from the month using LAST_DAY(sysdate) which returns 31-JUL-11. However When i perform a simple = comparison it doesn't provide the result..i am talking about suppose tablename.lastdateofmonth = LAST_DAY(sysdate) it doesn't provide the result but when i personally use tablename.lastdateofmonth = to_date('2011/07/31', 'yyyy/mm/dd') it provides the result.
last day helps make the current date because the last day's the month. nevertheless it keeps time. you have to trunc the values if you are planning to check them just by day-month-year. Truncing them will solve your condition.
tablename.lastdateofmonth = trunc(LAST_DAY(sysdate))
LAST_DAY(sysdate) will return the last date from the month such as the time part.
Appears like the information within the column lastdateofmonth is simply getting date part and also the imte part past due to 12:00 AM.
tablename.lastdateofmonth = TRUNC(LAST_DAY(sysdate))
last_day() preserves time element of sysdate. Utilize it along with trunc() such as this:
select * from table_name where lastdateofmonth = last_day(trunc(sysdate));