Get the last day of a month according to the date that is in the uipath cell

get the last day of a month according to the date that is in the UiPath cell


Columna A

Columna B


Use a loop to get each value

Datetime.DaysInMonth(currentorw("ColumnA").ToString.Split("\",StringSplitOptions.None)(2),currentorw("ColumnA").ToString.Split("\",StringSplitOptions.None)(1)) + currentorw("ColumnA").ToString.Split("\",2,StringSplitOptions.None)(1)

Basically Datetime.DayInMonth(Year,Month) will give the last day or the days in that month

the 1 and 2 that are are from the row?
or is it the function?

because the column has a lot of data

Captura de pantalla 2023-02-13 133315


Then use a direct excel formula …just add this formula in a new cell usign write cell and then use auto fill range activity…all will be added automatically


1 and 2 in above are from function only…only columnname is what you need to change…but yes for each might take time

The current method of excel formula is faster for this


I get this error


Edited it …please check this

Datetime.DaysInMonth(Cint(currentorw("ColumnA").ToString.Split("\",StringSplitOptions.None)(2)),Cint(currentorw("ColumnA").ToString.Split("\",StringSplitOptions.None)(1))) + "\" + currentorw("ColumnA").ToString.Split("\",2,StringSplitOptions.None)(1)


HI @PD14

Checkout this expression

(From d In dt.AsEnumerable
Let r = If(String.IsNullOrEmpty(d(0).Tostring),"",New DateTime(DateTime.ParseExact(d(0).ToString,{"dd/M/yyyy hh:mm:ss","dd/M/yyyy","M/dd/yyyy","M/dd/yyyy hh:mm:ss","d/M/yyyy hh:mm:ss","d/M/yyyy","M/d/yyyy","M/d/yyyy hh:mm:ss","dd/MM/yyyy","MM/dd/yyyy hh:mm:ss","MM/dd/yyyy","dd.MM.yyyy hh:mm:ss"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DatetimeStyles.None).Year,DateTime.ParseExact(d(0).ToString,{"dd/MM/yyyy","MM/dd/yyyy hh:mm:ss","MM/dd/yyyy","dd.MM.yyyy hh:mm:ss"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DatetimeStyles.None).AddMonths(1).Month,1).AddDays(-1).ToString("dd/MM/yyyy"))
Select dt2.LoadDataRow({d(0),r},True)).CopyToDataTable


Hello @PD14
Try this

  1. Read the Excel and save it as Dt
  2. Use For each loop and print the currentrow(datecolumn) to know the format of date.
    2.1 Then convert value into date time variable
ProcessDase= DateTime.ParseExact("17/2/2022","d/M/yyyy",System.Globalization.CultureInfo.InvariantCulture).AddMonths(1)

In ProcessDate variable, the format needs to update as your value.
If possible send some sample inputs, we tried to provide the XAML file for your better understanding.

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