Could any one explain this code logic,
and provide me alternate code in tera data...
What DBMS is this?
Looks like MS SQL Server, but this CURRENT_DATE.DAY is strange.
Would be easier if you add the current result, but this seems to return the last day of the current month:
EXTRACT(DAY FROM LAST_DAY(CURRENT_DATE))