D
developer
I want to substract a number of month from a specific date.
someone have a easy solution ?
Thanks
someone have a easy solution ?
Thanks
developer said:I want to substract a number of month from a specific date.
someone have a easy solution ?
-----Original Message-----
I want to substract a number of month from a specific date.
someone have a easy solution ?
Thanks
.
The DateTime.AddMonths with a negative number takes care of that!However, you should consider cases like: "What does March 30th -1 month
mean?" and deal with them appropriately.
Jon Skeet said:I'd suggest creating a new DateTime using the same fields as the
original date, but subtracting the number of months appropriately.
However, you should consider cases like: "What does March 30th -1 month
mean?" and deal with them appropriately.
Jay B. Harlow said:The DateTime.AddMonths with a negative number takes care of that!
However its not symmetrical, March 30th - 1 month, that date +1 month is not
March 30th. Which is always a problem with date arithmetic ;-)
Over time, I've worked out that the following are just some of the
nightmare worlds it's best not to delve too far into:
o Dates and times, with timezones etc