Siebel VB Language Reference > VB Language Reference >

Second Function


This standard VB function returns the second component (0 to 59) of a date-time value.

Syntax

Second(time)

Argument
Description

time

Any numeric or string expression that can evaluate to a date-time or time value

Returns

If the expression evaluates to a date-time or time value, the second component of that value; otherwise 0.

Usage

Time can be of any type, including strings, and the Second function attempts to convert the input value to a date-time value.

For Second to function without an error, the values passed to it must be in some form that can be interpreted as a time or date-time value. Thus, 13:26:39 or 1:45:12 PM returns valid results, but 1326 returns a 0.

The return value is a variant of vartype 2 (integer). If the value of time is NULL, a variant of vartype 1 (Null) is returned.

Example

This example displays the last saved date and time for a file whose name is entered by the user.

Sub Button_Click
   Dim filename as String
   Dim ftime
   Dim hr, min
   Dim sec
   Dim msgtext as String
i: msgtext = "Enter a filename:"
   filename = "d:\temp\trace.txt"
   If filename = "" then
      Exit Sub
   End If
   On Error Resume Next
   ftime = FileDateTime(filename)
   If Err <> 0 then
      Goto i:
   End If
   hr = Hour(ftime)
   min = Minute(ftime)
      sec = Second(ftime)
End Sub

See Also

Date Statement
DateSerial Function
DateValue Function
Day Function
Hour Function
Minute Function
Month Function
Now Function
Time Statement
TimeSerial Function
TimeValue Function
WebApplet_InvokeMethod Event
Year Function

Siebel VB Language Reference