# Hour

## Understanding the Hour Function

The Hour function in Power Fx returns the hour of a given time value. It takes a single argument, which can be a time value, a date/time value, or a text value representing a time. The function returns an integer between 0 and 23, representing the hour of the given time value.

Here’s an example of how to use the Hour function in Power Fx:

``` Hour(Now()) ```

This formula returns the current hour of the day, using the Now function to get the current date/time value.

## Converting Time Values

The Hour function is often used in conjunction with other functions to convert time values from one format to another. For example, you might have a text value representing a time in 12-hour format, like “3:30 PM”, and you need to convert it to a 24-hour format for use in a calculation. Here’s how you can do that with the Hour function:

``` Hour(Text(DateTimeValue("3:30 PM"),"[\$-en-US]hh")) ```

This formula uses the Text function to convert the text value “3:30 PM” to a date/time value, and then uses the Hour function to extract the hour value in 24-hour format.

Similarly, you can use the Hour function to convert a date/time value to a time value. Here’s an example:

``` Hour(DateAdd(Now(),-1,Days)) ```

This formula subtracts one day from the current date/time value using the DateAdd function, and then uses the Hour function to return the hour value of the resulting time value.

## Displaying Time Values

The Hour function can also be used to display time values in your Power Apps app. For example, you might want to display the current time in a label control. Here’s how you can do that with the Hour function:

``` Text(Hour(Now()),"[\$-en-US]hh:mm:ss tt") ```