Be the first user to complete this post

  • 0
Add to List

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

Hour()

Description:

The Hour function takes time as a parameter and returns a number between 0 and 23, that is the Hour of the time provided.

Format:

Hour(strTime)

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

Example :

Function FnHour()

Dim strTime

strTime = Time

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

End Function
Hour()
Hour()

________________________________________________________________________________________

Minute()

Description:

The Minute function takes time as a parameter and returns a number between 0 and 59, that is the minutes of hour of the time provided.

Format:

Minute(strTime)

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

Example:

Function FnMinute()

   Dim strTime

   strTime = Time

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

End Function
DateTime -Minute()
DateTime -Minute()

_________________________________________________________________________________________

Second()

Description:

The Second function takes time as a parameter and returns a number between 0 and 59, that is the seconds of minute of the time provided.

Format:

Second(strTime)

Arguments:
  • strTime
  • Manda­tory
  • Type: Time
  • Time, whose Seconds need to be calculated.

Example:

Function FnSecond()

    Dim strTime

  strTime = Time   

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

End Function

DateTime - Second()
Second()



Also Read:

  1. VBA Excel - Cells, Ranges and Offset : Range
  2. VBA-Excel: Date-Time Functions – DatePart()
  3. VBA-Excel: Select and Activate Cells - Activate
  4. VBA-Excel: Date-Time Functions – DateAdd()
  5. VBA-Excel: Create Array using Array() Function
  6. VBA-Excel: CurrentRegion
  7. VBA-Excel: Date-Time Functions – DateValue()
  8. VBA-Excel : Strings Functions – Instr