Here are some more Oracle SQL variations using LAST_DAY
for different use cases:
1. Get Last Day of Any Given Year & Month
✅ This will return 30-JUN-2024
.
2. Find Last Day of Previous, Current, and Next Month
✅ Dynamically fetches last days for previous, current, and next month.
3. Get Last Day of Financial Year (March 31st)
✅ If today is in 2024, this will return 31-MAR-2024.
4. Get Last Day of Calendar Year (December 31st)
✅ Returns 31-DEC-2024 if run in 2024.
5. Find the Number of Days in a Given Month
✅ This calculates the number of days in the current month.
6. Get the Last Weekday of the Month
✅ This finds the last weekday (Friday) of the current month.
7. Find the Last Sunday of the Month
✅ Adjust "SUNDAY"
to any day you want.
Here are more advanced Oracle SQL queries using LAST_DAY
for different scenarios:
8. Get Last Friday of the Month
✅ Returns the last Friday of the current month.
9. Get Last Working Day (Mon-Fri) of the Month
✅ Adjusts to the last Monday-Friday workday.
10. Find the Last Monday of the Month
✅ Adjust "MONDAY"
for other days.
11. Get the Last Date of Each Month in a Year
✅ Lists the last date of every month in 2024.
12. Get the Last Day of the Last 12 Months
✅ Gets last days for the past 12 months.
13. Get the Last Business Day of the Month (Excluding Weekends & Holidays)
✅ Excludes weekends and holidays.
14. Get Last Day of Previous Quarter
✅ Returns last day of the previous quarter.
15. Get Last Day of Current Quarter
✅ Returns last day of the current quarter.
16. Get Last Day of a Specific Quarter (e.g., Q3 2024)
✅ Returns 30-SEP-2024 (last day of Q3 2024).
17. Get the Last Day of a Leap Year February
✅ Returns 29-FEB-2024 for leap years.
18. Get the Last Day of the Last 5 Years
✅ Returns last days of the last 5 years.
19. Get the Last Day of Next 5 Years
✅ Returns last days of the next 5 years.
20. Get the Last Day of a Dynamic Fiscal Year (April - March)
✅ Returns 31-MAR-2025 if today is in 2024.