Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the equivalent DateAndTime.DateAdd in C#

I have an old code written in VB.Net and I am trying to convert it into c#. I am stuck on DateAndTime.DateAdd conversion for c#

DateAdd(DateInterval.Month, -1, Now).ToString("MMM")

This is my old vb.net code. It is getting the current month and subtracting – one month from it.

How do I achieve this c#?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use DateTime.AddMonths.

Pay attention:

Returns a new DateTime

var date = DateTime.Now.AddMonths(-1);
var stringDate = date.ToString("MMM");
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading