Hello everyone, I need two datetime variables:
Current date minus 3 months and then the first day of the month
Current date minus 1 month and the last day of the month How does this work?
Many thanks in advance.
Hello everyone, I need two datetime variables:
Current date minus 3 months and then the first day of the month
Current date minus 1 month and the last day of the month How does this work?
Many thanks in advance.
Hope this helps.
Now.AddMonths(-3).AddDays(-Now.Day+1)
Now.AddDays(-Now.Day)
You can use AddMonths function, AddDays Function and pass numeric values to get what you want.
Now.Day will give the day of month.
Thanks
Happy Automation!
DateAdd(DateInterval.Month,-3,Now)
The first day of a month is always 1 so…
New DateTime(DateAdd(DateInterval.Month,-3,Now).Year,DateAdd(DateInterval.Month,-3,Now).Month,1)
DateAdd(DateInterval.Month,-1,Now)
And then use DaysInMonth…
New DateTime(DateAdd(DateInterval.Month,-1,Now).Year,DateAdd(DateInterval.Month,-1,Now).Month,System.DateTime.DaysInMonth(DateAdd(DateInterval.Month,-1,Now).Year,DateAdd(DateInterval.Month,-1,Now).Month))
For the first scenario, use the below one to get the minus 3 months and get the first date of that month,
FirstDayOfMonth = New DateTime(Now.AddMonths(-3).Year, Now.AddMonths(-3).Month, 1)
For the second scenario, use the below expression to get the minus 1 month and get the last date of that month,
LastDayOfMonth = New DateTime(Now.AddMonths(-1).Year, Now.AddMonths(-1).Month, DateTime.DaysInMonth(Now.AddMonths(-1).Year, Now.AddMonths(-1).Month))
Hope it helps!!
Hey @Prisemuetchen
You can use this flow:
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.