Functions

M Time Functions

Time Functions

M time functions like Time.Hour extract time components.

Introduction to M Time Functions

M Time functions are used in Power Query to work with time data. They allow you to extract specific components of a time value, such as hours, minutes, and seconds. These functions are vital for transforming and analyzing time-related data.

Common M Time Functions

The most commonly used M Time functions include:

  • Time.Hour: Extracts the hour component from a time value.
  • Time.Minute: Extracts the minute component from a time value.
  • Time.Second: Extracts the second component from a time value.

Using Time.Hour Function

The Time.Hour function extracts the hour component from a given time. The syntax is as follows:

In this example, the Time.Hour function extracts the hour from 14:30:45, returning 14.

Using Time.Minute Function

The Time.Minute function extracts the minute component from a time value. The syntax is:

Here, the Time.Minute function extracts the minute from 14:30:45, resulting in 30.

Using Time.Second Function

The Time.Second function extracts the second component from a time value. The syntax is:

In this case, the Time.Second function extracts the second from 14:30:45, which is 45.

Combining Time Functions

By combining these functions, you can manipulate time values to suit your needs. For example, you might want to compare the hour and minute components of two different times.

This code compares two time values to determine if they share the same hour and minute. The result is a record indicating whether each component is the same.