TimeSerial Function

Calculates a serial time value for the specified hour, minute, and second parameters that are passed as numeric value. You can then use this value to calculate the difference between times.

Syntax:

TimeSerial (hour, minute, second)

Povratna vrijednost

Datum

Parametri:

hour: Any integer expression that indicates the hour of the time that is used to determine the serial time value. Valid values: 0-23.

minute: Any integer expression that indicates the minute of the time that is used to determine the serial time value. In general, use values between 0 and 59. However, you can also use values that lie outside of this range, where the number of minutes influence the hour value.

second: Any integer expression that indicates the second of the time that is used to determine the serial time value. In general, you can use values between 0 and 59. However, you can also use values that lie outside of this range, where the number seconds influences the minute value.

Examples:

12, -5, 45 znači 11, 55, 45

12, 61, 45 znači 13, 2, 45

12, 20, -2 znači 12, 19, 58

12, 20, 63 znači 12, 21, 4

Možete koristiti funkciju TimeSerial za pretvaranje vremena u jednu numeričku vrijednost koju možete koristiti za računanje vremenske razlike.

Funkcija TimeSerial vraća tip Variant gdje je VarType = 7 (Date). Ova vrijednost interno se sprema kao numerička vrijednost dvostruke preciznosti između 0 i 0.9999999999. Za razliku od funkcija DateSerial i DateValue, gdje se serijalizirana vrijednost datuma računa kao broj dana u odnosu na fiksan datum, sa vrijednostima koje vraća funkcija TimeSerial možete računati, no ne možete ih uspoređivati.

Funkciji TimeValue možete kao parametar proslijediti znakovni niz koji sadrži vrijeme. Međutim, funkciji TimeSerial možete proslijediti pojedinačne parametre (sate, minute, sekunde) kao posebne numeričke izraze.

Error codes:

5 Invalid procedure call

Primjer:

Sub ExampleTimeSerial

Dim dDate As Double, sDate As String

    dDate = TimeSerial(8,30,15)

    sDate = TimeSerial(8,30,15)

    MsgBox dDate,64,"Vrijeme kao broj"

    MsgBox sDate,64,"Formatirano vrijeme"

End Sub