Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Small method to calculate since time
Message
From
04/10/2011 10:00:08
John Baird
Coatesville, Pennsylvania, United States
 
 
To
04/10/2011 09:28:28
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01525501
Message ID:
01525548
Views:
50
This message has been marked as a message which has helped to the initial question of the thread.
>>Yes but your start time in this example is 2007 ... 3 years ago...
>
>Yes, and based on those numbers, it doesn't make any sense that we would have five years and 3 months completed since August 5th.
>
>Do you have any idea why?


Found this on stack overflow:
Public Class ClassDateOperation 
    Private prop_DifferenceInDay As Integer 
    Private prop_DifferenceInMonth As Integer 
    Private prop_DifferenceInYear As Integer 
 
 
    Public Function DayMonthYearFromTwoDate(ByVal DateStart As Date, ByVal DateEnd As Date) As ClassDateOperation 
        Dim differenceInDay As Integer 
        Dim differenceInMonth As Integer 
        Dim differenceInYear As Integer 
        Dim myDate As Date 
 
        DateEnd = DateEnd.AddDays(1) 
 
        differenceInYear = DateEnd.Year - DateStart.Year 
 
        If DateStart.Month <= DateEnd.Month Then 
            differenceInMonth = DateEnd.Month - DateStart.Month 
        Else 
            differenceInYear -= 1 
            differenceInMonth = (12 - DateStart.Month) + DateEnd.Month 
        End If 
 
 
        If DateStart.Day <= DateEnd.Day Then 
            differenceInDay = DateEnd.Day - DateStart.Day 
        Else 
 
            myDate = CDate("01/" & DateStart.AddMonths(1).Month & "/" & DateStart.Year).AddDays(-1) 
            If differenceInMonth <> 0 Then 
                differenceInMonth -= 1 
            Else 
                differenceInMonth = 11 
                differenceInYear -= 1 
            End If 
 
            differenceInDay = myDate.Day - DateStart.Day + DateEnd.Day 
 
        End If 
 
        prop_DifferenceInDay = differenceInDay 
        prop_DifferenceInMonth = differenceInMonth 
        prop_DifferenceInYear = differenceInYear 
 
        Return Me 
    End Function 
 
    Public ReadOnly Property DifferenceInDay() As Integer 
        Get 
            Return prop_DifferenceInDay 
        End Get 
    End Property 
 
    Public ReadOnly Property DifferenceInMonth As Integer 
        Get 
            Return prop_DifferenceInMonth 
        End Get 
    End Property 
 
    Public ReadOnly Property DifferenceInYear As Integer 
        Get 
            Return prop_DifferenceInYear 
        End Get 
    End Property 
 
End Class 
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform