Date formula

Hi Guys,

I have a formula for the date that will pick the next working date perfectly even if ran on a friday it will pick up mondays date. However i am now looking to modify that formula so that it picks the end of the month a date. The formula i have been using is as follows


Any help would be greatly appreciated

See this thread:

@Anthony_Humphries Thank you i have been able to get the last working day of the month however i need the date in a different format how would i go about doing this? i’ve added “MMddyyyy” into the formula but i get an error.

any thing else i can try? theres got to be a way

Now that you have the last day of the month in a datetime variable, do this:

If MyDatetime is your variable, to set the format to “MMddyyyy”, assign a string variable MyDateString to MyDatetime.ToString("MMddyyyy").

i have followed what you have said however i am not getting the desired result, it still gives me the results of ‘30’ strangely.

I’ve added the document so you can see what ive done

test.xaml (4.4 KB)

You’re assigning your datetime variable to an integer when it should be a datetime. You’re also returning the datetime and not the string you’ve assigned. Also, re-read the post I sent. The solution shows you how to get the last day in the month, but that’s what you have to set the day to, and not the entire datetime.

Is there a different solution? that solution doesn’t seem to be working for me. @Anthony_Humphries

If MyDatetime is your datetime variable, set MyDatetime.Day equal to the integer value provided in the post. There are other solutions, but most of the ones I can think of will be more complicated.

i don’t understand what you mean, sorry @Anthony_Humphries

Assign MyDatetime.Day to Now.DaysInMonth(Now.Year, Now.Month).

when typing in ‘DaysInMonth’ uipath is not registering Days only Day.
Not sure what i need to do to rectify this

this is what am currently getting

Ok, looked into this a little further, and the solution marked in my post does not work.

Assign your datetime to this instead:

Now.AddDays(Date.DaysInMonth(Now.Year, Now.Month) - Now.Day).

Apparently Now doesn’t have the DaysInMonth method, since it’s static and only works with Date.

Oh, and in your screenshot, when typing the date, you need to format your date.

So If I want it with the year followed by month followed by day with dashes between, I would use MyDatetime.ToString("yyyy-MM-dd") in the Type Into activity.

i am still getting the same issue here, when typing int DaysInMonth it doesn’t like the ‘s’ after day

Assign MyDatetime for my example instead of MyDatetime.Day.

aahh thast great thank you worked perfectly.

If i needed to enter the first day of next month what would i do differently? @Anthony_Humphries

Just add 1 in the AddDays formula.

so just after where it says AddDays(+1) then carry on with the formula? @Anthony_Humphries

Put the +1 after the formula in parentheses and it’ll work.