Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Calculate remaining days in the month

cstafford
8 - Asteroid

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.

11 REPLIES 11
Felipe_Ribeir0
16 - Nebula

Hi @cstafford 

 

One way of doing this

 

Felipe_Ribeir0_0-1674652752676.png

 

JamesCharnley
13 - Pulsar

@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:

 

JamesCharnley_0-1674652777567.png

 

Felipe_Ribeir0
16 - Nebula

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.

ShankerV
17 - Castor

Hi @cstafford 

 

Please make use of the functions datetimetoday() and datetimelastof month().

 

ShankerV_0-1674652982568.png

 

cstafford
8 - Asteroid

Thanks for the solution. I knew there had to be much better way!

cstafford
8 - Asteroid

Is their a way to calculate the number of days in the current month as well?

 

Jan = 31

Feb = 28

March = 31

etc.

ShankerV
17 - Castor

Hi @cstafford 

 

One way of doing this.

 

right(left(tostring(DateTimeLastOfMonth()),10),2)

 

ShankerV_0-1675114558705.png

 

Many thanks

Shanker V

 

ShankerV
17 - Castor

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

 

 

cstafford
8 - Asteroid

Thank you!

Labels