Can anyone show me how to create a vb function that will allow me to take two dates which are stored in a database, and then determine the numbers of days in between them?
Any help would be greatly appreciated.
Thanks
![]() |
0 |
![]() |
dim diff as integer = date1.DayOfYear - date.DayOfYear
Hope this helps!
GRJ
![]() |
0 |
![]() |
Use DateDiff function:
Dim diff as Integer = DateDiff(DateInterval.Day, Date1, Date2)
Parameter DateInterval.Day return result in days, but there are too:
DateInterval.Month
DateInterval.Year
DateInterval.Hour
DateInterval.Minute
....
Ângelo Paulo
![]() |
0 |
![]() |
I have an ASP.NET application that schedules/reserves items for a block of time in days. Here is the code that I use to determine the number of days from two date strings that were input from textbox fields in my form:
Private Function NumberOfDaysRequested(ByVal startDate as string, endDate as string) As Int
{
Dim startDate as DateTime
Dim endDate as DateTime
Dim dateDiff as TimeSpan
startDate = DateTime.Parse(startDate)
endDate = DateTime.Parse(endDate)
dateDiff = endDate.Subtract(startDate)
return dateDiff.Days
}
![]() |
0 |
![]() |