cancel
Showing results for
Did you mean:
Helper I

## Calendar Problem

Hi all,

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
Community Support

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
4 REPLIES 4
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
Helper I

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.

Community Support

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
Helper I

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

Announcements

#### Power Platform Community Call

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

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

Top Solution Authors
Top Kudoed Authors
Users online (3,642)