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

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

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,642)