cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TANC
Regular Visitor

Editable table with time functions

Hi

I want to make an editable table that logs the time in and time out of an activity

 

My Sharepoint list has the following fields

Date: Datefield

Name: Lookup to another Sharepoint list

TimeIn: date/Time

TimeOut: Date/Time

TotalTime: Calculated to give me the difference in minutes - (TimeOut-TimeIn)*1440)

 

I was thinking if i could get the Date field to automatically populate the date section of the two time fields but im not sure how to do it in a Power apps gallery rather than form and how to add the time in

1 ACCEPTED SOLUTION

Accepted Solutions
v-albai-msft
Community Support
Community Support

Hi @TANC ,

Do you want to auto populate TimeIn column when edit this record and auto populate TimeOut column when end of editing(and save it)?

If yes, I would suggest you use Text column to keep the time. I did a simple test on my side for reference:

1. This is my list called “TimeList” with three Text columns called “TimeIn”, “TimeOut” and “TotalTime”:

v-albai-msft_0-1615973633491.png

This is my gallery(I add a label to keep ThisItem.TotalTime):

v-albai-msft_1-1615973633495.png

2. With the default app template, when click the arrow button next each record, it will go to the DetailedScreen. So go to the DetailedScreen, add “Set(VarTimeIn,Now())” function into the OnSelect property of the pencil/edit button, so that when you edit an item, it will save current time into this variable.

v-albai-msft_2-1615973633499.png

3. Go to edit screen, set the TimeIn control to the variable just created:

v-albai-msft_3-1615973633501.png

4. This time, we should keep the current time into TimeOut column when submitting changes, so set OnSelect property of save button to below(use title to lookup this record, and change its TimeOut column to Now(), also calculate time difference and keep the value into its TotalTime column):

 

SubmitForm(EditForm1);Patch(TimeList,LookUp(TimeList,Title=DataCardValue5.Text),{TimeOut:Now(),TotalTime:DateDiff(DateTimeValue(DataCardValue6.Text),Now(),Seconds)})

 

For test purpose, I use Seconds inside DateDiff(). On your side, the code should be:

SubmitForm(EditForm1);Patch(TimeList,LookUp(TimeList,Title=DataCardValue5.Text),{TimeOut:Now(),TotalTime:DateDiff(DateTimeValue(DataCardValue6.Text),Now(),Minutes)})

v-albai-msft_4-1615973633505.png

This time, when you edit a record, it will auto populate with the edit time and when you save your changes, it will auto populate the exit time.

v-albai-msft_5-1615973633507.png

Best Regards,

Allen

View solution in original post

2 REPLIES 2
Silvester
Helper I
Helper I

I can't get your question straight forward, can you take a snapshot to illustrate it?

v-albai-msft
Community Support
Community Support

Hi @TANC ,

Do you want to auto populate TimeIn column when edit this record and auto populate TimeOut column when end of editing(and save it)?

If yes, I would suggest you use Text column to keep the time. I did a simple test on my side for reference:

1. This is my list called “TimeList” with three Text columns called “TimeIn”, “TimeOut” and “TotalTime”:

v-albai-msft_0-1615973633491.png

This is my gallery(I add a label to keep ThisItem.TotalTime):

v-albai-msft_1-1615973633495.png

2. With the default app template, when click the arrow button next each record, it will go to the DetailedScreen. So go to the DetailedScreen, add “Set(VarTimeIn,Now())” function into the OnSelect property of the pencil/edit button, so that when you edit an item, it will save current time into this variable.

v-albai-msft_2-1615973633499.png

3. Go to edit screen, set the TimeIn control to the variable just created:

v-albai-msft_3-1615973633501.png

4. This time, we should keep the current time into TimeOut column when submitting changes, so set OnSelect property of save button to below(use title to lookup this record, and change its TimeOut column to Now(), also calculate time difference and keep the value into its TotalTime column):

 

SubmitForm(EditForm1);Patch(TimeList,LookUp(TimeList,Title=DataCardValue5.Text),{TimeOut:Now(),TotalTime:DateDiff(DateTimeValue(DataCardValue6.Text),Now(),Seconds)})

 

For test purpose, I use Seconds inside DateDiff(). On your side, the code should be:

SubmitForm(EditForm1);Patch(TimeList,LookUp(TimeList,Title=DataCardValue5.Text),{TimeOut:Now(),TotalTime:DateDiff(DateTimeValue(DataCardValue6.Text),Now(),Minutes)})

v-albai-msft_4-1615973633505.png

This time, when you edit a record, it will auto populate with the edit time and when you save your changes, it will auto populate the exit time.

v-albai-msft_5-1615973633507.png

Best Regards,

Allen

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,350)