Hi i’m new using uipath and its been great experience . Im wondering if the uipath can autodetect the date from the system and input the begin date and end date per month.
Now is 4 January 2018
so i need to input 01-01-2018 and 31-01-2018 in text column
Sorry for my poor english and i hope its enough to understand my question
@delf, Use the following in Assign Activity
dateTime beginDate = new DateTime(now.Year,now.Month,1)
dateTime lastDate = beginDate.AddMonths(1).AddDays(-1)
Your expected output :
string startDate = beginDate.ToString(“dd-MM-yyyy”)
string endDate = lastDate.ToString(“dd-MM-yyyy”)
Note: Use this startDate and endDate Variable in you rinput activity (TypeInto)
instead use this
Can you elaborate why this is better?
if today date = 4th Jan 2018 then
beginDate.AddMonths(1).AddDays(-1) will give 3rd Feb 2018 which is wrong. Cause it is subtracting only one day where day can be any day of the month 1 to 31
@AkshaySandhu, Thanks for the attention !
And it works fine.
Adding the following link for your reference, Add Months Remarks.
Example given in ref link is correct where date is static with date 12/31/2015, we are adding only months.
by default while adding months if date is not in the range of resulted month then date is keep on reducing by 1 (please correct me if I am wrong) until it is in range.
@AkshaySandhu, Sorry if it is wrongly mapped. Refer the explanation given in Remarks Section in the above link.
The AddMonths method calculates the resulting month and year, taking into account leap years and the number of days in a month, then adjusts the day part of the resulting DateTime object
Hello @599712 my bad I didnt saw that your are using beginDate as date to get the last day of the current month. Your answer is correct .
Sorry for misunderstanding
Thanks all for the reply… I will try later after i’m finished doing some tweak in my workbook.
Thanks all… already using this and worked…thank you