VBA - Second Function



The Second Function returns a number between 0 and 59 that represents the second of the hour for the specified time stamp.

Syntax

Second(time) 

Example

Add a button and add the following function.

Private Sub Constant_demo_Click()
   msgbox("Line 1: " & Second("3:13:25 PM"))
   msgbox("Line 2: " & Second("23:13:45"))
   msgbox("Line 3: " & Second("2:20 PM"))
End Sub

When you execute the above function, it produces the following output.

Line 1: 25
Line 2: 45
Line 3: 0
vba_date_time.htm
Advertisements