


Second
Purpose
Returns an integer between 0 and 59, inclusive, that represents the second of
the minutes corresponding to the time provided as an argument.
Arguments
Second( number )
Notes
The argument number is any numeric expression that can represent a date and/or time from January
1, 100 through December 31, 9999, where January 1, 1900 is 2. Numbers to the
left of the decimal point in number represent the date; numbers to the right represent the time. Negative numbers
represent dates prior to December 30, 1899. If number is Null, this function returns a Null.
Example
In this example, the TimeValue function creates a Variant of VarType 7 (Date) for midnight. The Hour,
Minute, and Second functions determine the hour, minute, and second values so the
difference can be calculated.
Midnight = TimeValue("23:59:59")
// Get differences.
HourDiff = Hour(Midnight) - Hour(Now)
MinuteDiff = Minute(Midnight) - Minute(Now)
SecondDiff = Second(Midnight) - Second(Now) + 1
If SecondDiff = 60 Then
MinuteDiff = MinuteDiff + 1
// Add 1 to minute.
SecondDiff = 0 // Zero seconds.
End If
If MinuteDiff = 60 Then
HourDiff = HourDiff + 1
// Add 1 to hour.
MinuteDiff = 0 // Zero minutes.
End If
TotalMinDiff = (HourDiff * 60) + MinuteDiff
// Get totals.
TotalSecDiff = (TotalMinDiff * 60) + SecondDiff
Msg = "There are a total of " & Format(TotalSecDiff, "#,##0")
Msg = Msg & " seconds until midnight. That translates to "
Msg = Msg & HourDiff & " hours, " & MinuteDiff
Msg = Msg & " minutes, and " & SecondDiff & " seconds."
MsgBox Msg
// Display message.