[INCLUDE]
IsGregYear

[CODE]
Public Sub LongToDateTripple(ByVal DateID As Long, ByRef xYear As Long, ByRef xMonth As Long, ByRef xDay As Long)
  Dim xGreg As Long
  Dim xLong1 As Long
  
  DateID = DateID - 1&
  xYear = Fix(DateID / 146097) * 400&
  DateID = DateID Mod 146097
  xLong1 = Fix(DateID / 36524)
  If xLong1 = 4& Then xLong1 = 3&
  xYear = xYear + xLong1 * 100&
  DateID = DateID - xLong1 * 36524
  xYear = xYear + Fix(DateID / 1461&) * 4&
  DateID = DateID Mod 1461&
  xLong1 = Fix(DateID / 365&)
  If xLong1 = 4& Then xLong1 = 3&
  xYear = xYear + xLong1
  DateID = DateID - xLong1 * 365& + 1&
  xYear = xYear + 1&
  
  xGreg = -CLng(IsGregYear(xYear))
  Select Case DateID
    Case 1& To 31&: xMonth = 1&: xDay = DateID: xGreg = 0&
    Case 32& To 59& + xGreg: xMonth = 2&: xDay = DateID - 31&: xGreg = 0&
    Case 60& + xGreg To 90& + xGreg: xMonth = 3&: xDay = DateID - 59&
    Case 91& + xGreg To 120& + xGreg: xMonth = 4&: xDay = DateID - 90&
    Case 121& + xGreg To 151& + xGreg: xMonth = 5&: xDay = DateID - 120&
    Case 152& + xGreg To 181& + xGreg: xMonth = 6&: xDay = DateID - 151&
    Case 182& + xGreg To 212& + xGreg: xMonth = 7&: xDay = DateID - 181&
    Case 213& + xGreg To 243& + xGreg: xMonth = 8&: xDay = DateID - 212&
    Case 244& + xGreg To 273& + xGreg: xMonth = 9&: xDay = DateID - 243&
    Case 274& + xGreg To 304& + xGreg: xMonth = 10&: xDay = DateID - 273&
    Case 305& + xGreg To 334& + xGreg: xMonth = 11&: xDay = DateID - 304&
    Case 335& + xGreg To 365& + xGreg: xMonth = 12&: xDay = DateID - 334&
    End Select
  
  xDay = xDay + xGreg
  End Function
