I have a label value 1859 in minutes and I would like to convert it to something like 1 day 6 hours and 59 minutes.
Can anyone help, please?
Can anyone help, please?
Dim m As Long = 1859*DateTime.TicksPerMinute
Dim p As Period = dateutils.PeriodBetween(0,m)
Log(p.Days & " day " & p.Hours & " hrs " & p.Minutes & " min") 'yields 1 day 6 hrs 59 min
Sub Activity_Create(FirstTime As Boolean)
Log(IncorrectMinutesToNiceString(2400000))
Log(CorrectMinutesToNiceString(2400000))
End Sub
Sub IncorrectMinutesToNiceString(minutes As Int) As String
Dim p As Period = dateutils.PeriodBetweenInDays(0,minutes * DateTime.TicksPerMinute)
Return $"${p.Days} days, ${p.Hours} hours and ${p.minutes} minutes"$
End Sub
Sub CorrectMinutesToNiceString(minutes As Int) As String
Dim t As Long = minutes * DateTime.TicksPerMinute
Dim days, hours, minutes As Int
days = t / DateTime.TicksPerDay '(24 hours day)
hours = (t Mod DateTime.TicksPerDay) / DateTime.TicksPerHour
minutes = (t Mod DateTime.TicksPerHour) / DateTime.TicksPerMinute
Return $"${days} days, ${hours} hours and ${minutes} minutes"$
End Sub
Here is the code using PeriodBetweenInDays and PeriodBetween EST zone: Both yield the same correct result. Where is the problem my friend?To prove it check your code (after you fix point number one) with this value: 24000000
Dim m As Long = 24000000
Dim p As Period = dateutils.PeriodBetween(0,m)
Log(p.Days & " day " & p.Hours & " hrs " & p.Minutes & " min") 'yields 0 day 6 hrs 40 min
Dim m As Long = 24000000
Dim p As Period = dateutils.PeriodBetweenInDays(0,m)
Log(p.Days & " day " & p.Hours & " hrs " & p.Minutes & " min") 'yields 0 day 6 hrs 40 min