ConvertToDays is a function within ddGlobal and forms part of the ddDate suite of macros.  It is used to calculate the number of days that there is in the text value “YYYY-MM” from.  This has limited use in Excel but is used in several other macros to do some basic date calculations

Assume the date is “2013-03″, then the answer will be 735,338.25.  This is achieved by taking =(2013 x 365.25) + (3 x 30)

Function ConvertToDays(ActiveDate As Variant)
'The function is used to determine the number of days there are in the format
'YYYY-MM this is used in the function LargeDate
'Written by Denis Dell on 03/12/2001
    If Mid(ActiveDate, 5, 1) <> "-" Then
        ActiveDate = 0
        ActiveDate = CleanDate(ActiveDate)
    End If
    ConvertToDays = (Val(Left(ActiveDate, 4)) * 365.25) + (Val(Right(ActiveDate, 2)) * 30)
End Function
This entry was posted in Articles, ddGlobal, Tips and tagged , . Bookmark the permalink.

Leave a Reply