Divide a period by month

Hello, how are you?

I have a job to do where when I receive a date period, example: 01/01/2018 to 01/01/2022

From there, I need to generate a spreadsheet with the beginning and end days of each month within that date period, for example:
01/01/2018 and 01/31/2018

Is it possible to do this in UiPath?

thank you for your attention


Can you please confirm me. if i understand correctly!

  1. You will get 2 dates. In that 2 dates you have to generate the dates till that date.


Input Dates :

FirstDate = 01/01/2018
SecondDate = 03/01/2018

Your expected output is :


and so on.

Is this what you’re expecting?


Hi @Luca_Alcalde

You can use a while loop to compare the two mentioned dates.
assign intermediateDate=DateTime.ParseExact(startDate,“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddMonths(1).AddDays(-1).toString(“MM/dd/yyyy”)

Assuming that you have the data in a datatable format you can filter using select or linq query using the start date and intermediate date and write in separate sheets.
Dt1 = Dt1.Select(“DateColumn >= #startDate# AND DateColumn <= #intermediateDate#”).CopyToDataTable
Once you’ve written the data while in the loop,
startdate= DateTime.ParseExact(intermediateDate,“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture).AddDays(1).toString(“MM/dd/yyyy”)

Happy Automation!


  1. Create a System.DateTime variable to store the start date, e.g. StartDate = DateTime.ParseExact("01/01/2018", "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
  2. Create a System.DateTime variable to store the end date, e.g. EndDate = DateTime.ParseExact("01/31/2018", "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture)
  3. Add a while loop with condition StartDate <= EndDate
  4. Inside the while loop, you can get the date using StartDate.ToString("MM/dd/yyyy"), then increment it by 1 day using StartDate.AddDays(1). This will loop will generate every day between the start date and end date.
1 Like

hello everything is fine?

I’ll explain better

Date format is MM/dd/yyyy

FirstDate = 01/01/2018
SecondDate = 01/01/2020

from this I need to generate a spreadsheet with the columns start date and end date, as follows:


Hi @Luca_Alcalde ,

Attaching the output:
and the Xaml file which you can use and modify to get the data from spreadsheet
DateRange.xaml (10.5 KB)
Dates.xlsx (8.0 KB)

Updated XAML and Excel File

Hope this Helps!

1 Like


Yes, I got you…

Yes it is possible with UiPath.

Try Like this:

  1. Insert StartDate and EndDate in the Spreadsheet.
  2. Use AutoFill range activity to generate the Dates

That’s it

AutoFill Reference:


1 Like

Hi @Luca_Alcalde ,

Maybe also check on the below method as an alternate :

DT1 = Enumerable.Range(0,Cint(DateDiff("M",CDate(FirstDate),CDate(SecondDate)))).Select(Function(x)DT1.Rows.Add("'"+CDate(FirstDate).AddMonths(x).ToString("MM/dd/yyyy"),"'"+CDate(FirstDate).AddMonths(x+1).AddDays(-1).ToString("MM/dd/yyyy"))).CopyToDatatable

Here, DT1 is a Datatable variable which is created using the Build Datatable activity with the Required Columns. FirstDate and SecondDate are the String type variables which contains the Start Date and the End Date of the date ranges that we need to compute.

Note : An Additional Quote "'" is added at the beginning of the dates just to preserve the formats in the Excel sheet. We could remove it or maybe have another method of preserving the format as required.

Workflow Visual :

Output :


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.