Click here to Skip to main content
15,924,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
take in your consideration Intersection of intervals and gabes between intervals
Posted

When you retrieve the dates from the database, do this:

VB
Dim span As TimeSpan = toDate - FromDate


One thing to be aware of is that the TimeSpan object does not have a representation for months, so you're going to have to estimate it by establishing how many days are n a month (most folks use 30 in a situation like this). So, to find the months and days covered by the TimeSpan object, you'd have to do this:

VB
Dim months As Integer = span.Days / 30
Dim days As Integer = span.Days - (months * 30)
 
Share this answer
 
You can use Date.Compare function tow compare two Date by passing Two Date as a parameter.See Example :
VB
Date.Compare(Date1, Date2)

Or there is another way to Compare Two Dates. You can use DateDiff Function
which is more suitable as compare to Compare. See Example :
VB
DateDiff(DateInterval.Day, Date1, Date2)

I hope it will help you. :)

--MKB
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900