Minute Function

Returns an integer between 0 and 59, inclusive, that represents the minute of the hour corresponding to the time provided as an argument.

Syntax

Minute(dateexpression)

Remarks

The argument dateexpression is any numeric expression or string 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 dateexpression represent the date; numbers to the right represent the time.  Negative numbers represent dates prior to December 30, 1899.

If dateexpression is Null, this function returns a Null.

Day Function

Hour Function

Month Function

Now Function

Second Function

Time, Time\$ Functions

Time, Time\$ Statements

Weekday Function

Year Function

Minute Function 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.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

Sub Form_Click ()

Dim HourDiff, MinuteDiff, Msg, SecondDiff   ' Declare variables

Dim Instant, Midnight, TotalMinDiff, TotalSecDiff

Midnight = TimeValue("23:59:59")

Instant = Now                               ' Get current time.

HourDiff = Hour(Midnight) - Hour(Instant)   ' Get differences.

MinuteDiff = Minute(Midnight) - Minute(Instant)

SecondDiff = Second(Midnight) - Second(Instant) + 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.

End Sub