Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

VBA-Excel: Date-Time Functions – Hour(), Minute(), Second()

Hour()

Description:

The Hour func­tion takes time as a para­me­ter and returns a num­ber between 0 and 23, that is the Hour of the time provided.

Format:

Hour(strTime)

Arguments:
  • str­Time
    • Manda­tory
    • Type: Time
    • Time, whose hours need to be calculated.

Exam­ple :

Function FnHour()

Dim strTime

strTime = Time

MsgBox "Current Hour is -> " & Hour(strTime)    

End Function
Hour()

Hour()

________________________________________________________________________________________

Minute()

Description:

The Minute func­tion takes time as a para­me­ter and returns a num­ber between 0 and 59, that is the min­utes of hour of the time provided.

Format:

Minute(strTime)

Arguments:
  • str­Time
    • Manda­tory
    • Type: Time
    • Time, whose Minute need to be calculated.

Exam­ple:

Function FnMinute()

   Dim strTime

   strTime = Time

   MsgBox "Current Minutes of the Hour is -> " & Minute(strTime)

End Function
DateTime -Minute()
Date­Time –Minute()

_________________________________________________________________________________________

Second()

Description:

The Sec­ond func­tion takes time as a para­me­ter and returns a num­ber between 0 and 59, that is the sec­onds of minute of the time provided.

Format:

Second(strTime)

Arguments:
    • str­Time
    • Manda­tory
    • Type: Time
    • Time, whose Sec­onds need to be calculated.

Exam­ple:

Function FnSecond()

    Dim strTime

  strTime = Time    

  MsgBox "Current Seconds of the Minute are -> " & Second(strTime)    

End Function

 

DateTime - Second()

Sec­ond()

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: