❔ [Error] The added or subtracted value results in an un-representable DateTime.
I have following function:
I don't know why but sometimes I get exception:
"The added or subtracted value results in an un-representable DateTime"
how can I deal with it?
7 Replies
You can only have a Date value between 1/1/0001 and 12/31/9999 11:59:59 PM
you'd get this exception if you're trying to represent a date that is not between those dates
hmm no way in my case
interesting that I don't get smth like ".. was not recognized as a valid DateTime"
what are the values of begin and end?
I will try to find them
no idea what
AddPERIODRow
does but other than that, the error is coming from day.AddDays(1)
if it is then i believe end date is 31/12/9999
with some timespan
in a for loop after the first loop, day = day.AddDays( 1 )
gets executed first before the loop executes day < end
If you want to account for that edge case, you need to do something like this.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.