cancel
Showing results for
Did you mean:
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.

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
Super User

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.

3 REPLIES 3
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.

Frequent Visitor

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

Super User

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.

Announcements

#### 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.