sqloraclebi-publisher

SQL query to check the last day of the month is not a sunday


I want to calculate the last day of the month, but if this date is a sunday then the below query should not give any output.

SELECT * FROM DUAL WHERE LAST_DAY(SYSDATE) = SYSDATE

I am using it in a trigger hence I only want the above query it give an output when the last day of the month is not a sunday. Which function to use to get the day of the month or to tweak this query ?


Solution

  • Like this:

    select 1
    from dual
    where to_char(last_day(sysdate),'D') != 1;
    

    Depending on your NLS-settings you may have to change the constant or use an NLS-parameter in to_char().