cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
m365newuser
Frequent Visitor

Lookup date to check if its weekday

Hello I have built an app, to record my hours worked and upload that to my sharepoint list.

 

Screen Shot 2021-01-15 at 4.23.13 PM.png

 

I want to use the "Calculate Pay" button, to lookup if the date I have submitted is weekday or weekend and then calculate my pay = (number of hours * weekend pay rate/ weekday pay rate). Please advise on how to proceed.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@m365newuser ,

The Default StartOfWeek is Sunday unless you specify otherwise and this is day 1 with Saturday 7 (hence my code).

The other two are only place holders showing you where to put in your calculation code. I have used names on the controls (In/Out Date/Hour/Minute) that you will have to replace with yours, but I am sure you will get the idea

With(
   {
      wTime:
      DateDiff(
         InDate.SelectedDate + 
         Time(
            Value(InHour.Selected.Value), 
            Value(InMinute.Selected.Value), 
            0
         ),
         OutDateValue2.SelectedDate + 
         Time(
            Value(OutHour.Selected.Value), 
            Value(OutMinute.Selected.Value), 
            0
         ),
         Hours
      )
   },
   If(
      WeekDay(OutDate.SelectedDate) = 1 ||
      WeekDay(OutDate.SelectedDate) = 7,
      wTime*YourWekendRate,
      wTime*YourWeekdayRate,
   )
)

You may also have to use Minutes instead of Hours and divide your rate by 60 if you want partial hours.

 

 

View solution in original post

3 REPLIES 3
WarrenBelz
Super User
Super User

Hi @m365newuser ,

The formula would be something like this

If(
   WeekDay(YourOutDatePicker.SelectedDate) = 1 ||
   WeekDay(YourOutDatePicker.SelectedDate) = 7,
   YourWeekendPayCalc,
   YourWeekDayPayCalc
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Thank you for help. 

Could you explain the logic?

From my limited understanding by default 0 is Sunday till 6 which is Saturday unless we specify StartOfWeek.Monday for example.

Furthermore, in your formula is YourWeekendPayCalc a variable? I was hoping to write it as a formula directly without storing the value in a variable and then calling the variable to do the calculation

 

@m365newuser ,

The Default StartOfWeek is Sunday unless you specify otherwise and this is day 1 with Saturday 7 (hence my code).

The other two are only place holders showing you where to put in your calculation code. I have used names on the controls (In/Out Date/Hour/Minute) that you will have to replace with yours, but I am sure you will get the idea

With(
   {
      wTime:
      DateDiff(
         InDate.SelectedDate + 
         Time(
            Value(InHour.Selected.Value), 
            Value(InMinute.Selected.Value), 
            0
         ),
         OutDateValue2.SelectedDate + 
         Time(
            Value(OutHour.Selected.Value), 
            Value(OutMinute.Selected.Value), 
            0
         ),
         Hours
      )
   },
   If(
      WeekDay(OutDate.SelectedDate) = 1 ||
      WeekDay(OutDate.SelectedDate) = 7,
      wTime*YourWekendRate,
      wTime*YourWeekdayRate,
   )
)

You may also have to use Minutes instead of Hours and divide your rate by 60 if you want partial hours.

 

 

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PWREduCon768x460.png

Join us at PWR EduCon - A Power Platform Conference

Learn from the top Power BI, Power Apps, Power Automate & Power Virtual Agents experts!

Top Solution Authors
Top Kudoed Authors
Users online (2,172)