count year to year between two dates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • irfanEmmaneul
    New Member
    • Aug 2014
    • 2

    count year to year between two dates

    i'm creating assets tracking data base, i have to set asset depreciation every year of asset life, i am using datediff() but it count total duration of asset, i want that starting date and ending date and computer count integer number until the ending date for example purchased asset date 12-Aug-2010 useful life of Asset is 12-Aug-2014, between both dates computer account automatically number that has been passed ..
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3653

    #2
    irfanEmmaneul,


    Try a public function similar to this:

    Code:
    Public Function WhatIsAge(AssetDate As Date) As String
        Dim intYears As Integer
        Dim intMonths As Integer
        Dim intDays As Integer
        intYears = Format(Date - AssetDate, "yy")
        intMonths = Month(Date - AssetDate) - 1
        intDays = Day(Date - AssetDate)
        WhatIsAge = "Asset is " & _
            intYears & " years, " & _
            intMonths & " months, " & _
            intDays & " days old."
    End Function
    It may be a good place to start. Hope this hepps!

    Comment

    Working...