Time.Second

Updated on

Time.Second is a Power Query M function that extracts the second component from a given time, datetime, or datetimezone value. The function returns the second component as a number.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Time.Second( dateTime as any ) as nullable number

Description

Time.Second returns the second component of the provided time, datetime, or datetimezone value, dateTime and returns it as a number.

Examples

Let’s look at how to use the Time.Second function. This function, while categorized under Time functions, can extract the second value from time, datetime, and datetimezone values.

Extracting Seconds from a DateTime Value

When you have a datetime value and you want to extract the second component from it, you can use the Time.Second function. Here’s an example:

// Output: 1
Time.Second( #datetime( 2024, 9, 15, 20, 30, 1 ) )

In this example, #datetime( 2024, 9, 15, 20, 30, 1 ) represents September 15, 2024, at 8:30:01 PM. The Time.Second function pulls out the second part from this datetime value, which is 1.

Extracting Seconds from a DateTimeZone Value

The function also works with datetimezone values. This means you can extract the second part from a datetime value that includes time zone information. Here’s how:

// Output: 5
Time.Second( #datetimezone( 2024, 9, 15, 20, 45, 5, 2, 30 ) )

In this case, #datetimezone( 2024, 9, 15, 20, 45, 5, 2, 30 ) represents September 15, 2024, at 8:45:05 PM with an offset of +2 hours and 30 minutes from UTC. The Time.Second function extracts the second part, which is 5.

Extracting Seconds from a Time Value

You can apply the function to a time value as well.

// Output: 0
Time.Second( #time( 12, 10, 0 ) )

In this scenario, #time( 12, 10, 0 ) represents 12:10 PM. The Time.Second function extracts the second value, which is 0.

Other functions related to Time.Second are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/time-second

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy