How can I get Next month of todays ?

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

e.g today is 23-12-2004, i should get nextmonth of today 23-01-2005
I know DaysAdd(noofdays) ,but I don't know noofdays should be 30 or 31 ?
Thanks a lot
 
Use the Datetime.AddMonths method. You don't have to worry about 30 or 31
days. AddMonths will take care of it.

' This will give 23-01-2005
Dim dt As DateTime = DateTime.Parse("23-12-2004").AddMonths(1)

hope that helps..
Imran.
 
Agnes,
Given a DateTime variable, you can use DateTime.AddMonths to add months.

Dim today As DateTime = #12/23/2004#
Dim nextMonth as DateTime = today.AddMonths(1)

DateTime also has methods for adding Days, Hours, Minutes, Milliseconds, and
Seconds to a DateTime value.

Hope this helps
Jay
 
Thanks a lot
Jay B. Harlow said:
Agnes,
Given a DateTime variable, you can use DateTime.AddMonths to add months.

Dim today As DateTime = #12/23/2004#
Dim nextMonth as DateTime = today.AddMonths(1)

DateTime also has methods for adding Days, Hours, Minutes, Milliseconds, and
Seconds to a DateTime value.

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top