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.
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.