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

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

 

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

View solution in original post

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

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (43,297)