Question : a couple of date/time questions

Hi Experts,

I'm kind of new to the MonthCalendar and have some easy date/time questions (VB.NET 2008):

1) Is there an easy way to determine if the date/day is the last in the month?

2) How do I loop through dates?
    ForEach startDate to laterDate...
    (I need to be able to loop through dates in different months and years. For instance from 15 May 2010 to 31st of January 2012)

3) Is there an easy way to calculate the date an exact number of days forward, backward?
Say it's the 15 of May and you want to get the date 60 days earlier/later.


Regards,
Perry

Answer : a couple of date/time questions

1) Find the last day of the month:

Date.DaysInMonth(YourYearHere, YourMonthHere)

Change YourYearHere for the year and YourMonthHere for the month you want to get the last day.

2) Please check this link:

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_25071818.html

3) Subtract days:

Dim dt As Date = Now
dt = dt.AddDays(-30)

Add days:

Dim dt As Date = Now
dt = dt.AddDays(30)

jppinto
Random Solutions  
 
programming4us programming4us