dateAudytStart (DateTime), default: New DateTime(Now.AddMonths(-12).Year,Now.AddMonths(-12).Month,1)
and
dateAudytEnd (DateTime), default: New New DateTime(Now.Year,Now.Month,1).AddDays(-1)
These dates are right, when I want to start UiPath audit e.g. for April at the end of May.
If I would like to start on the beginning of the next month (June), I have to change default:
start: New DateTime(Now.AddMonths(-12).Year,Now.AddMonths(-13).Month,1)
end: New DateTime(Now.AddMonths(-1).Year,Now.AddMonths(-1).Month,1).AddDays(-1)
to receive the same result (start: 2019-05-01 and end: 2019-04-30 - 12 previous month).
Generally I do audyt for April from about 2019-05-26 to 2019-06-10.
How I would like to create fixed variables, which give me the same result (when I start my audit 2019-05-28 or 2019-06-05.
start date gives 2018-06-30 (today should 2018-05-01)
end date gives 2019-05-30 (should 2019-04-30)
Generally to get perdiod in format yyyy-MM I use Now.AddDays(-50).ToString(“yyyy-MM”)
I subtract 50 days to get the same value, independently I run UiPath at the end of month, or on the begining.
Unfortunately I have problem with date in format yyyy-MM-dd (If I subtract 50 days, I have wrong result in day - year and month is ok).
You can use the above statements to get the dates and implement some additional logic to decide what should happen at the end of month or starting of month.
use below
"Start Date: “+now.AddDays(If(now.Day>10,-(now.Day+1),-(now.Day-1+datetime.DaysInMonth(now.Year,now.Month-1)))).AddYears(-1).ToString(“yyyy-MM-dd”)+” End Date: "+now.AddDays(If(now.Day>10,-(now.Day),-(now.Day+datetime.DaysInMonth(now.Year,now.Month-1)))).ToString(“yyyy-MM-dd”)
Start date is correct when the period is from 1st do 10th of the month.
It the date is later, eg. 30.06.2019, I received 2018-05-30, instead 2018-06-01.
If my present date is 11.07.2019, I got 2018-06-29 instead 2018-07-01
use this
"Start Date: “+now.AddDays(If(now.Day>10,-(now.Day-1),-(now.Day-1+datetime.DaysInMonth(now.Year,now.Month-1)))).AddYears(-1).ToString(“yyyy-MM-dd”)+” End Date: "+now.AddDays(If(now.Day>10,-(now.Day),-(now.Day+datetime.DaysInMonth(now.Year,now.Month-1)))).ToString(“yyyy-MM-dd”)