web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Calculating nigth hours
Power Automate
Unanswered

Calculating nigth hours

(0) ShareShare
ReportReport
Posted on by 10

How can i separate nights hours from day hours in Sharepoint or PowerApp when for example employee started working at 4pm and finished at 12am, this will be 2hrs of days and 6 hrs with nigth differential. My PowerApp has 2 daytime pickers, (two datetime columns in sharepoint) with starting time and end time. Employee can work only 4hrs where 2hrs could be on days and the other 2hrs as nigth, so im not trying to do shifts. Also is not current time, this will be use to calculate a cost for a schedule request. Any help will be appreciated.

 

BTW i asked in the SharePoint community, they sent me here, hopefully you guys can help me out.

Categories:
  • Vele2 Profile Picture
    10 on at

    Let me try to simplify what Im looking for, I want to count the hours  worked at nigth to be in a separate column. There are two date/time pickers, start and end time. If the employee starts at 4AM and ended at 8AM i need a column for those 2hrs worked at nigth to calculate the nigth differential pay. Another scenario is that the employee started at 2PM and ended at 9PM, 4hrs of day and 3 nigth Hrs. Any idea would be greatly appreciated.

  • wskinnermctc Profile Picture
    6,519 Moderator on at

    I would do some algebra in hidden/non-visible boxes in your power app based on the Start and End times selected.

    You also need to identify when Night hours begin and when Night hours end. Like 6:00PM - 6:00AM are the night hours range.

     

    So the first thing I would have it do is identify if the Start Time or End Time is within a night shift.

    -If Start Time is in Night hours - Yes

    -If End Time is in Night hours - Yes

     

    The I would do a check on the results and take actions:

    -If "No, No" just get total hours and put them in the SharePoint day hours column

    -If "Yes, Yes" just get total hours and put them in the SharePoint night hours column

    -If "Yes, No" get the difference between Start Time (which is at night) and 6:00AM which is End of Night hours and put in the Night hours column of SharePoint. Then get the difference between End Hours (which is during day) and 6:00AM and put in the Day hours column of SharePoint.

    -If "No, Yes" get the difference between Start Time (which is during day) and 6:00PM which is Start of Night hours and put in the Day hours column of SharePoint. Then get the difference between End Hours (which is at night) and 6:00PM and put in the Nigh hours column of SharePoint.

     

    Does that look like something you can do?

  • Vele2 Profile Picture
    10 on at

    I do get the idea, the code part is difficult to me, im used to SAP and Excel, fairly new to this, but I will continue my research to try to accomplish your suggestion

  • wskinnermctc Profile Picture
    6,519 Moderator on at

    You would do the coding in the Power App, not in Power Automate or in SharePoint. It's basically If statements in hidden boxes.

    Not to give you the run around, but this question should be in the Power Apps forum. I don't see how you would be using Power Automate with this.

    https://powerusers.microsoft.com/t5/Power-Apps-Community/ct-p/PowerApps1 

     

    Another approach to think about (which isn't exactly clean, but it gets the job done transparently) is to make a separate SharePoint list that has the times listed out. You can then identify if it is a Day or Night hour. That might make your conditions easier.

    I made a power app that had employee schedule drop down boxes. I used my TimeHoursList which is a SharePoint list as the source for my dropdowns. Then I had hidden boxes that were based on lookups from the dropdown. These hidden boxes used numerical times from the SharePoint list to make calculations. I did this approach since it was easier for me; however, it isn't as clean since the App needs to reference external list to complete calculations. 

     

    wskinnermctc_0-1677516101722.png

     

     

     

    Just trying to give some possible ideas,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 330

#2
11manish Profile Picture

11manish 282 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 123

Last 30 days Overall leaderboard