Imports System
Public Module Module1
Function SplitDays(totalDays As Integer) As (Years As Integer, Months As Integer, Days As Integer)
Dim startDate As New DateTime(1970, 1, 1)
Dim endDate As DateTime = startDate.AddDays(totalDays)
Dim years As Integer = endDate.Year - startDate.Year
Dim months As Integer = endDate.Month - startDate.Month
Dim days As Integer = endDate.Day - startDate.Day
' Normalize negative values
If days < 0 Then
months -= 1
Dim prevMonth As DateTime = endDate.AddMonths(-1)
days += DateTime.DaysInMonth(prevMonth.Year, prevMonth.Month)
End If
If months < 0 Then
months += 12
years -= 1
End If
Return (years, months, days)
End Function
Public Sub Main()
Dim result = SplitDays(452)
Console.WriteLine($"{result.Years} years, {result.Months} months, {result.Days} days")
End Sub
End Module
' run:
'
' 1 years, 2 months, 28 days
'