2
I need to take current date and subtract 3 months.
Bang making conversions and subtracting 3 but will go wrong to turn the year, in January for example will result in month -2.
I believe that there is a better way of doing this.
2
I need to take current date and subtract 3 months.
Bang making conversions and subtracting 3 but will go wrong to turn the year, in January for example will result in month -2.
I believe that there is a better way of doing this.
2
Yes, there is a more suitable way. The structure DateTime
has the method AddMonths
, to subtract a number amount is to use this method with a negative parameter.
For example
var data = new DateTime(2017, 01, 01);
var novaData = data.AddMonths(-3);
It worked perfectly, thank you very much.
Browser other questions tagged c# datetime date
You are not signed in. Login or sign up in order to post.
Now it worked out, I’m familiar with the platform. Thanks for the tips.
– Antonio Gomes