Anyone know a good way of determining how many minutes there are from 'now' to midnight tonight? Actually I think my question is how to get the date/time for midnight tonight and use it to compare with the date/time now as I can already compare two dates..
Sub MinutesTillMidnight As Int
Dim midnight As Long = DateUtils.SetDate(DateTime.GetYear(DateTime.Now), _
DateTime.GetMonth(DateTime.Now), DateTime.GetDayOfMonth(DateTime.Now))
midnight = DateTime.Add(midnight, 0, 0, 1)
Dim p As Period = DateUtils.PeriodBetweenInDays(DateTime.Now, midnight)
Return p.Hours * 60 + p.Minutes
End Sub
' Make sure the date format does not include time
DateTime.DateFormat = DateTime.DeviceDefaultDateFormat
' Add 1 day to today and parse the date this will give you midnight
' Then subtract the current time
Dim MinsToMidnight As Long
MinsToMidnight = DateTime.DateParse(DateTime.Date(DateTime.Add(DateTime.Now, 0, 0, 1))) - DateTime.Now
' Calculate the minutes from now until midnight
MinsToMidnight = MinsToMidnight / DateTime.TicksPerMinute
Log(MinsToMidnight)