Calculate remaining days in the month
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Looking for ways to streamline a process to calculate the remaining days in the current month within Alteryx. I know how to do it mathematically, but with all the features in Alteryx, I am guessing their might be a more efficient way? Look for ideas or best practice.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@cstafford There's a function within the formula tool called DateTimeDiff which we can use here. You'll want your parameters to be another function called DateTimeLastOfMonth() and your date/today's date whichever you want, and your date part which is 'day'. It'd look like this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Now looking at the solution that @JamesCharnley provided, i would replace this part of my solution DateTimeTrim(DateTimeToday(), 'lastofmonth') by DateTimeLastOfMonth().
It gives the same result (2023-01-31) but it is much more directly and clear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks for the solution. I knew there had to be much better way!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Is their a way to calculate the number of days in the current month as well?
Jan = 31
Feb = 28
March = 31
etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @cstafford
One way of doing this.
right(left(tostring(DateTimeLastOfMonth()),10),2)
Many thanks
Shanker V
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @cstafford
right(left(tostring(DateTimeLastOfMonth()),10),2)
The formula will work dynamically as DateTimeLastOfMonth() gives the last day of the month.
Using left and right function, the last day of the month is extracted for our solution.
So for this current month January 31 is displayed.
But for February 28 for normal year and 29 for leap year will be displayed.
Many thanks
Shanker V
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you!
