Categories
- All Categories
- Oracle Analytics and AI Learning Hub
- 44 Oracle Analytics and AI Sharing Center
- 20 Oracle Analytics and AI Lounge
- 278 Oracle Analytics and AI News
- 56 Oracle Analytics and AI Videos
- 16.2K Oracle Analytics and AI Forums
- 6.4K Oracle Analytics and AI Labs
- Oracle Analytics and AI User Groups
- 103 Oracle Analytics and AI Trainings
- 20 Oracle Analytics and AI Challenge
- Find Partners
- For Partners
Number of Days in Month
Greetings Community, is there any workaround possible that returns "Number of Days" in a Month. For ex, March = 31, April = 30 and so on and so forth.
I've tried many combinations from here:
but nothing seems to work.
Best Answer
-
Hi,
You need to start from a date, being a day in the month and year you need to know the number of days (because February has different days depending on the year).
Then, what you can do is to add 1 month to that date and remove the number of day of the month of your date and get the number of day for the date you got (it was the end of the month).
Here an example using CURRENT_DATE:
DAYOFMONTH(TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, TIMESTAMPADD(SQL_TSI_MONTH, 1, CURRENT_DATE)))
You can easily apply this formula to any date you have.
Just keep in mind that it would faster and "safer" (every user will always get the right number) if you add that information to your time dimension as an attribute.
0

