Hi pjain,
That expression is hard coded to the year 2018 although you can use it if it serves the purpose of what you are working on.
I just took a look at some vbscripts and found that the Blue Prism functions were giving the equivalent support in providing the desired results.
Below expression supports leap year or any other dates.
The input should be passed as a
Date but will need to be customised if one needs to pass only the month and the year because at least both of these are required to consider leap year and month scenarios.
Calc stage with expression:
View attachment 1535171125093.png
Expression (in text format):
AddDays(MakeDate(1, ToNumber(FormatDate(AddMonths([Inputdate], 1), "MM")), ToNumber(FormatDate(AddMonths([Inputdate], 1), "yyyy"))), -1)
The basic logic is as follows:
-
AddMonths: Go to the next month of the input date
-
FormatDate: To get only the month and the year portion which are required for the MakeDate function
-
MakeDate: Format the month and year of that date as the 1st day of month
-
AddDays: Subtract 1 day from the 1st day of next month
Leap month and year:
View attachment 1535171267565.png
First month of a year:
View attachment 1535171402379.png
Last month of a year:
View attachment 1535171456389.png
Monthend with 30 days:
View attachment 1535171515591.png