TimeValue

How to Use the Power Fx TimeValue  Function in Power Apps

What is the TimeValue Function?

The TimeValue function is a Power Fx function that converts a text string that represents a time into a time value in Power Apps. The syntax for the TimeValue function is as follows:


TimeValue(❰Text String❱)


The Text String argument should be a text string that represents a time in the format "hh:mm:ss", where "hh" represents the hours, "mm" represents the minutes, and "ss" represents the seconds.

Using the TimeValue Function in Power Apps

To use the TimeValue function in Power Apps, you need to follow a few simple steps:

1. Open the Power Apps app where you want to use the TimeValue function.

2. Create a new formula by clicking on the fx button in the formula bar.

3. Type in the TimeValue function syntax along with the text string argument.

4. Press Enter to evaluate the formula.

Here's an example of how to use the TimeValue function in Power Apps:


TimeValue(“12:30:00”)


This formula will return a time value of 12:30:00 PM.

Formatting the TimeValue Function Output

By default, the TimeValue function will return a time value in the format "hh:mm:ss AM/PM". However, you can format the output of the TimeValue function to display the time value in a different format.

To format the output of the TimeValue function, you can use the FormatDateTime function in Power Fx. The syntax for the FormatDateTime function is as follows:


FormatDateTime(❰DateTime❱, ❰Format String❱)


The DateTime argument should be a date and time value, and the Format String argument should be a text string that specifies the format of the date and time value.

Here's an example of how to use the FormatDateTime function to format the output of the TimeValue function:


FormatDateTime(TimeValue(“12:30:00”), “h:mm tt”)


This formula will return a formatted time value of "12:30 PM".

Using the TimeValue Function with Other Power Fx Functions

The TimeValue function can be used in combination with other Power Fx functions to create powerful and dynamic formulas in Power Apps.

For example, you can use the TimeValue function in combination with the Now function to calculate the time difference between two dates and times. Here's an example of how to use the TimeValue function with the Now function in Power Apps:


TimeValue(Now()) – TimeValue(“12:30:00”)


This formula will return the time difference between the current time and 12:30 PM.

In conclusion, the Power Fx TimeValue function is a powerful tool that can be used to convert a text string that represents a time into a time value in Power Apps. By following the steps outlined in this article, you can easily use the TimeValue function in your Power Apps formulas and create dynamic and powerful apps.

Power Apps Training Courses by G Com Solutions (0800 998 9248)