Hello, I have a field in my SQL db that is time only. The date portion is stored in a different column because it is tied to a table. Also, the users will only want to enter the time portion into the form. I have been able to get the app to store the time of 10:15 am into the database (10:15:00.0000000). When I view that value in a gallery it shows as PT10H15M. I am trying to get the text input field to reflect the value that is in the gallery as 10:15 am after they have submitted the form. I have tried various formulas using DateTimeValue, TimeValue, TimeZoneOffset, but I do not know how to handle it without the date portion. I have read the "time after time" and "party time" posts and I do not see anything I can use. Is there a way to use the timezoneoffset function with just the hour and minute?
Solved! Go to Solution.
Hi @PaigeJ ,
Do you want to update time to sql and display time in powerapps?
Could you tell me this time field's data type?
I assume that it is time(7) data type.
I've made a similar test for your reference:
1)in my test, the time field named test3, my table named '[dbo].[testtime]'
2)insert a gallery to display the sql table
set the gallery's Items:
'[dbo].[testtime]'
if you set the label's Text to :
ThisItem.test3
It will display in this format:
PT12H45M10S
So you just need to get the number before "H","M" and "S"
3)try to set the label's Text:
Time(
Value(If("H" in ThisItem.test3,Match(ThisItem.test3,"\d+").FullMatch,0)),
Value(Substitute(If("M" in ThisItem.test3,Match(ThisItem.test3,"\d+M").FullMatch,0),"M","")),
Value(Substitute(If("S" in ThisItem.test3,Match(ThisItem.test3,"\d+S").FullMatch,0),"S",""))
)
Then this column will display in time format.
Best regards,
Try following this post:
https://powerusers.microsoft.com/t5/Building-Power-Apps/Dealing-with-Time-from-SQL-and-doing-compari...
------------
If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
Hi @PaigeJ ,
Do you want to update time to sql and display time in powerapps?
Could you tell me this time field's data type?
I assume that it is time(7) data type.
I've made a similar test for your reference:
1)in my test, the time field named test3, my table named '[dbo].[testtime]'
2)insert a gallery to display the sql table
set the gallery's Items:
'[dbo].[testtime]'
if you set the label's Text to :
ThisItem.test3
It will display in this format:
PT12H45M10S
So you just need to get the number before "H","M" and "S"
3)try to set the label's Text:
Time(
Value(If("H" in ThisItem.test3,Match(ThisItem.test3,"\d+").FullMatch,0)),
Value(Substitute(If("M" in ThisItem.test3,Match(ThisItem.test3,"\d+M").FullMatch,0),"M","")),
Value(Substitute(If("S" in ThisItem.test3,Match(ThisItem.test3,"\d+S").FullMatch,0),"S",""))
)
Then this column will display in time format.
Best regards,
User | Count |
---|---|
221 | |
99 | |
94 | |
55 | |
36 |
User | Count |
---|---|
273 | |
104 | |
104 | |
60 | |
60 |