Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

Dates between two dates within one month


Hi all, 


Couldn't find this answer but seems doable


I want to count the amount of days within one month between two dates. For example, if the start date is 8/1/2017 and the end date is 10/31/2017,  I want to return 31 because there are 31 days in August and when I run it again in September, I'd want it to return 30.


I tried using DATETIMEDIFF but that didn't include the part of days within a certain month. Is that doable?



The datetimediff should work. The exact formula to use is -




The '+1' in the end is to include the starting date. You may also replace the dates with variables that are of "date" type.


Thanks for the reply rohanonline! 


I updated the formula to include the +1 but it still seems to be including the entire range. In your example below, you have the two dates as within the same month. If the two dates are in different months (which is what I have), should that do the same?


An example from my data set is: start date 8/1/2017 & end date 10/25/2017

What I'd like returned is:

When I run the workflow in August, return 31

When I run the workflow in September, return 30

When I run the workflow in October, return 25

@MKM - It seems I understood the question incorrectly earlier.


What I understand now is that you will have 3 dates - start date, end date and run date.


Hence, in the example,


start date = 8/1/2017

end date = 10/25/2017


Then if, run date = 8/10/2017, the answer should be 31

if, run date = 9/10/2017, the answer should be 30

if, run date = 10/10/2017, the answer should be 25

if, run date = 11/10/2017, the answer should be 0


If this is correct, then please try using the attached workflow. Do let me know if it works or not. Thanks


Thanks for the attachment! Just reading the formula you added, I think it should work. However, I'm noticing that I can't add the date column name in place of the "Start" and "End" in your formula. Is it possible to use this formula while referring to a column field where all the values in the column are dates as oppose to a particular date value? 


Thank you again for all the help rohanonline!!

I am tempted to say that it should work fine. Not sure why you can't add the date column name. It would be better if you can share your workflow along with the sample data so that I can help better.

Here's a sample of the date structure in our data (I can't send the actual file since it contains client information) 


Start DateEnd DateDays in August


What I was hoping to do was use the formula you mentioned, but reference the "Start Date" and "End Date" column headers so that I can apply it to each row. I'm pretty sure your formula would do the same thing, output-wise, as what I have in the third column, though I'm not sure it includes the "N/A" portion when there are no days in that month. 


Thanks again!!

Please see the attached. This gives the exact result as you have mentioned in the table below.


Thanks rohanonline!!! I think this worked. For those that come back n/a, it seems like it flipped the effective start & end date. Any idea why? Doesn't really impact the result, just curious. 


Thank you again!!!


Hi, I created a reportdate_id for unique report date, I want to generate dates between every two unique report dates and load it in to a different table. I am thinking to create a macro to do that but not sure how. Can anyone help me with that ?



report_idreportdate Newtable      
19/13 report_id      
29/15 19/13     
39/17 19/14