DateAndTime.Second(DateTime) Method

Definition

Returns an integer value from 0 through 59 representing the second of the minute.

C#
public static int Second(DateTime TimeValue);

Parameters

TimeValue
DateTime

Required. A Date value from which you want to extract the second.

Returns

An integer value from 0 through 59 representing the second of the minute.

Examples

The following example uses the Second function to obtain the second of the minute from a specified time. In the development environment, the time literal is displayed in short time format using the locale settings of your code.

VB
Dim thisTime As Date
Dim thisSecond As Integer
thisTime = #4:35:17 PM#
thisSecond = Second(thisTime)
' thisSecond now contains 17.

Remarks

You can also obtain the second of the minute by calling DatePart and specifying DateInterval.Second for the Interval argument.

Applies to

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also