I’ve had this assign activity in my workflow for months and it’s never given me issues until today:
New DateTime(now.Year, now.Month, DateTime.DaysInMonth(now.Year, now.addmonths(-2).Month)).tostring(“dd”)
Basically, I just need to capture the number of days 2 months ago. I keep getting the error in the title of this post. Any help or easy fix would be appeciated.
You mean…you would like to get total days in July(sep-2) right? i.e 31, from any given months?
Code which you are using inside itself will give you the answer for that…
Use Below code to get 2 month before day
@arivu96 - Below code will give current day -2 months…which is always today’s day…
OP does not want that… Please read the requirement…
Well the result of that today is 9/31/2021 and there is no such date.
If you’re trying to get the number of days 2 months ago, then it’s just the last part of your expression: DateTime.DaysInMonth(now.Year, now.addmonths(-2).Month)).tostring(“dd”)
However, that’s not quite correct. You have to subtract two months from the current date THEN get the year and month, so it will work if it’s January or February and has to flip the year back one.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.