Categories
- All Categories
- Oracle Analytics and AI Learning Hub
- 34 Oracle Analytics and AI Sharing Center
- 20 Oracle Analytics and AI Lounge
- 273 Oracle Analytics and AI News
- 48 Oracle Analytics and AI Videos
- 16.2K Oracle Analytics and AI Forums
- 6.3K Oracle Analytics and AI Idea Labs
- Oracle Analytics and AI User Groups
- 101 Oracle Analytics and AI Trainings
- 16 Oracle Analytics and AI Challenge
- Find Partners
- For Partners
Does DV has last_date function?
Summary
Does DV has last_date function?
Content
I need to create a calculation "Days left in MTD". The SQL is last_day(current_date) - current_date. However I am not able to find last_day function as a calendar function in DV. Is there a way to achieve this?
Answers
-
This function isn't standard SQL, so DVD doesn't have the function itself but you have all you need to calculate it ...
You have CURRENT_DATE and by using TIMESTAMPADD and some logic you easily get to the last day of the month.
The idea is to first get the 1st day of the next month based on the current date, by first subtracting the number of days of month from CURRENT_DATE (by using DAYOFMONTH), adding 1 month by using TIMESTAMPADD and then calculate the difference compared the CURRENT_DATE by using TIMESTAMPDIFF and subtract 1 (because you used the 1st of next month and not the last of current month).
Done !
0
