How to get dates in between two dates of different month?

Hi All,

I am having
from date: 28/10/2019
to date : 08/11/2019

i want to get the dates in between these two and put it into one string array .

but it’s getting assign arithmetic operation resulted in an overflow

so if there’s a solution let me know it…

1 Like

Hello @SOURAV_KUMAR_DAS
Follow Following Steps-

  • Store your From Date in FromDate variable and its type should be DateTime .
  • Similarly store Todate in ToDate variable.
  • Now Create on Temporary TempDate Variable of DateTime.
  • Use While Loop and give the condition as Temdate < ToDate.
  • Display Tempdate or You Can add it In Collection Using Add To Collection.
  • Increase the Tempdate Using TempDate.Adddays(1).
    so it will give you all the dates between two dates.
    Regards
1 Like

Hi Sir,
Can you show it me in workflow…

@SOURAV_KUMAR_DAS,

Check this xaml, it may help you. My system date format is MM/dd/yyyy. So finally I have converted it to dd/MM/yyyy as per your requirements.

GetDatesBetween2Dates.xaml (6.0 KB)

3 Likes

Hi sarathi125 Sir,

I could download the workflow but it’s showing error.

@SOURAV_KUMAR_DAS,

Declare two DateTime Variables named as startDate and endDate, then an array with Datetime type.

Then in an assign activity pass this query to the datetime array.

Enumerable.Range(0, 1 + [endDate].Subtract(startDate).Days).[Select](Function(offset) startdate.AddDays(offset)).ToArray()
3 Likes

2 Likes

hello @SOURAV_KUMAR_DAS
Find the attached workflow.GetDates_Between_Two_dates.xaml (6.0 KB)

2 Likes

Hi Sir,

I got your solution now I want to write those dates into excel.

I am getting error on foreach loop

@SOURAV_KUMAR_DAS
Add that Build Data Table Above the While Loop
Add Add Data Row Inside the While Loop.

1 Like

Hi Sir,

The data row of for each should be added in the while loop Sir…?

@SOURAV_KUMAR_DAS
yes it should be Added in While Loop…because we are not adding those dates in any collection.if we doesn’t add in While Loop It will take only Last date.
For your understanding i Have made Changes in workflow so take a look it.GetDates_Between_Two_dates.xaml (7.9 KB)

1 Like

Hi Sir,

Thank You Sir for your solution.
Keep it on Sir…

1 Like

Hi jitendra_123 Sir,
If I want to exclude Saturday and Sunday from those days, what should be done.

@SOURAV_KUMAR_DAS
Use If Condition and use following code in it.
TempDate.DayOfWeek.ToString<>"Saturday" Or TempDate.DayOfWeek.ToString <>"Sunday"
Then in the Then part move that Add Data Row.

4 Likes

Hi jitendra_123 Sir,

This is the area know Sir…

@SOURAV_KUMAR_DAS
Yes, Is It working for you?

1 Like

Hi Sir,

For confirmation I have shared you the image…

Hi jitendra_123 Sir,

No Sir it is not working Sir, it’s getting Saturday as well as Sunday dates in the excel sheet.

@SOURAV_KUMAR_DAS
Find attached workflow.GetDates_Between_Two_dates.xaml (8.6 KB)

5 Likes