Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Small method to calculate since time
Message
De
04/10/2011 10:00:08
John Baird
Coatesville, Pennsylvanie, États-Unis
 
 
À
04/10/2011 09:28:28
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01525501
Message ID:
01525548
Vues:
51
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 
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform