The Time function in PowerApps is used to create a time value from separate hour, minute, and second components. This function is particularly useful when you need to construct time values dynamically based on user input or other variables.
PowerApps – Time() function Syntax
Time(Hour, Minute, Second)
- Hour: The hour component of the time (0 to 23).
- Minute: The minute component of the time (0 to 59).
- Second: The second component of the time (0 to 59).
Notes:
- Invalid Inputs: Ensure that the inputs for hour, minute, and second are within valid ranges (0-23 for hours, 0-59 for minutes and seconds). Use validation to prevent out-of-range values.
- Default Values: Set default values for the dropdowns or input controls to avoid issues with empty selections.
PowerApps – Create Basic time value
To create a time value representing 3:45:30 PM:
This returns a time value of 3:45:30 PM.
PowerApps – Create basic time value Using Variables
Suppose you have variables HourValue, MinuteValue, and SecondValue holding numerical values, and you want to create a time value:
Time(HourValue, MinuteValue, SecondValue)
PowerApps – Combine time with Date
You can combine the Time function with the Date function to create a complete date-time value. Suppose you have a date value and you want to add a specific time to it:
DateValue + Time(15, 30, 0)
This adds 3:30 PM to the specified date value.