difference between to dates

capdevs

Member
Joined
Dec 31, 2005
Messages
9
Location
next time
Programming Experience
1-3
hi guys ,

i want to take diference between two dates
i m use this code for retrive days and month


code:
DateDiff(DateInterval.Day, FirstDate, SecondDate)

required:

11/25/2005 - 01/07/2006

should ans:
1 month and 13 days


Please send me answer of this question withs code

regards
:confused:
 
VB.NET:
Dim firstdate As New Date(2005, 11, 25)
Dim seconddate As New Date(2006, 1, 7)
Dim ts As TimeSpan = seconddate.Subtract(firstdate)
Const daysinmonth As Double = 365 / 12
Dim months As Integer = ts.Days \ daysinmonth
Dim days As Integer = ts.Days Mod daysinmonth
MsgBox(months & " months and " & days & " days")
 
Back
Top