cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HF306
Helper I
Helper I

Calendar Problem

Hi all, 

 

Image.png

 

 

 

 

 

 

 

 

 

 

 

 

 

My No of Days for leave request app calendar does not work properly. IT does not show the proper number. Leave date is April 20 and Return date is 22 April. It should show 2 days but rather 172800000. Also, how do I make Saturday and Sunday as public holiday and if leave is taken on the same day for example leave date is April 20 and return date is April 20, how to make it 0.5?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @HF306,

I just give you choices to select, you should combine these as conditions in an If statement.

Modify your Default property as below:

If(
    DateDiff(
        DatePicker1.SelectedDate,
        DatePicker2.SelectedDate,
        Days
    ) = 0,
    0.5,
    RoundDown(
        DateDiff(
            DatePicker1.SelectedDate,
            DatePicker2.SelectedDate,
            Days
        ) / 7,
        0
    ) * 5 + Mod(
        5 + Weekday(DatePicker2.SelectedDate) - Weekday(DatePicker1.SelectedDate),
        5
    )
)

Qi

Best Regards,
Qi

View solution in original post

4 REPLIES 4
v-qiaqi-msft
Community Support
Community Support

Hi @HF306,

Could you please share a bit more about your scenario, how you set the Default of the Text input corresponding to the No of Days data card?

Note that DatePicker1 represents the start date and the DatePicker2 represents the end date.

1). Do you want to calculate the days difference between two dates?

Generally, we calculate the date difference using the DateDiff() function.

For your scenario, please try the formula as below:

DateDiff(DatePicker1.SelectedDate,DatePicker2.SelectedDate,Days)

2). Do you want to calculate the days difference between two dates excluding weekends?

RoundDown(
    DateDiff(
        DatePicker1.SelectedDate,
        DatePicker2.SelectedDate,
        Days
    ) / 7,
    0
) * 5 + Mod(
    5 + Weekday(DatePicker2.SelectedDate) - Weekday(DatePicker1.SelectedDate),
    5
)

3). Do you want to make it 0.5 day if the user leave and return at the same day?

If(DateDiff(DatePicker1.SelectedDate,DatePicker2.SelectedDate,Days)=0,"0.5")

Hope it could help.

Regards,

Qi

 

Best Regards,
Qi
HF306
Helper I
Helper I

Hi @v-qiaqi-msft , 

 

Image.png

 

Number 3 works, I entered the function at Default. Thank you so much!

 

Where do I enter the function for Number 1 and Number 2?

 

My Start date is DataCardValue_LeaveDate and Leave date is DataCardValue_ReturnDate.

 

Hi @HF306,

I just give you choices to select, you should combine these as conditions in an If statement.

Modify your Default property as below:

If(
    DateDiff(
        DatePicker1.SelectedDate,
        DatePicker2.SelectedDate,
        Days
    ) = 0,
    0.5,
    RoundDown(
        DateDiff(
            DatePicker1.SelectedDate,
            DatePicker2.SelectedDate,
            Days
        ) / 7,
        0
    ) * 5 + Mod(
        5 + Weekday(DatePicker2.SelectedDate) - Weekday(DatePicker1.SelectedDate),
        5
    )
)

Qi

Best Regards,
Qi

View solution in original post

oh okay, it worked!! thank you so much qi !!!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,188)