I am looking for the bot to be able to calculate the number of days in the month and then add/subtract 1 to that.
E.g. april has 30 days so i need the but to be able to enter 30/04/2020 +/- 1
I have a code that can give me the end of the month but every month is different
If you have the calculation for the end of the month stored in a variable (e.g. MyDatetime), and the variable is a Datetime datatype, you can use MyDatetime.AddDays(1) to get the day after, and MyDatetime.AddDays(-1) to get the day before.
If your date is a string formatted as dd/MM/yyyy, you’ll need to convert it to a datetime first. If MyStr is your date as a String datatype, you can set MyDatetime to Datetime.ParseExact(MyStr, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture), and then you can use the AddDays method on MyDatetime.
Hi,
Great thanks that has worked, however when i am running the bot it wont always be 1 day that needs to be added or deleted e.g. some pdf will have 9 days that need to added some will have 4 days to be subtracted.
How can i add this to the code? @Anthony_Humphries
You’ll need to create a variable of type Int32 to store the days. You can put this variable in place of the hard-coded 1 or -1. You’ll need to use an activity to get this number from wherever you’re storing the days.
It looks like you’re assigning a string to your variable. The value of the variable must be set to an integer, and the datatype of the variable must be Int32.