cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TB05
Helper III
Helper III

How to create a date range for calendar?

Hi,  

I created a calendar and would like a user to select a date range to add time to a SharePoint list.

Would I need to create a collection to get the range??  I'm not sure how to capture the date range.  

TB05_0-1636994203565.png

This is the Items code of the galleryCalendar:

//calculates both the current day and the next day
ForAll(
Sequence(42),
{Value: varFirstDayofMonth + Value - 1 - Weekday(
varFirstDayofMonth,
StartOfWeek.Sunday
) + 1,
NextDay: varFirstDayofMonth + Value - 1 - Weekday(
varFirstDayofMonth,
StartOfWeek.Sunday
) + 2}
)

 

 

This is OnSelect code in the gallery:

 Set(
varFirstDayofMonth,
Date(
Year(ThisItem.Value),
Month(ThisItem.Value),
1
)
);

1 ACCEPTED SOLUTION

Accepted Solutions
v-jefferni
Community Support
Community Support

Hi @TB05 ,

 

Could you please check if you have posted the proper formula that OnSelect of the gallery?

 

Anyway, if you would like to create data range in the calendar, you can set a variable or a collection with a single record that includes two columns: StartDate and EndDate. With the help of IsBlank() function, you could make the app automatedly know into which column the user want to fill the clicked date:

If(
   IsBlank(varDateRange.StartDate) || (!IsBlank(varDateRange.StartDate) && !IsBlank(varDateRange.EndDate)),
   Set(varDateRange, {StartDate: Date(Year(ThisItem.Value),Month(ThisItem.Value),1), EndDate: Blank()}),
   IsBlank(varDateRange.EndDate),
   Set(varDateRange, {EndDate: Date(Year(ThisItem.Value),Month(ThisItem.Value),1)})
)

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

3 REPLIES 3
v-jefferni
Community Support
Community Support

Hi @TB05 ,

 

Could you please check if you have posted the proper formula that OnSelect of the gallery?

 

Anyway, if you would like to create data range in the calendar, you can set a variable or a collection with a single record that includes two columns: StartDate and EndDate. With the help of IsBlank() function, you could make the app automatedly know into which column the user want to fill the clicked date:

If(
   IsBlank(varDateRange.StartDate) || (!IsBlank(varDateRange.StartDate) && !IsBlank(varDateRange.EndDate)),
   Set(varDateRange, {StartDate: Date(Year(ThisItem.Value),Month(ThisItem.Value),1), EndDate: Blank()}),
   IsBlank(varDateRange.EndDate),
   Set(varDateRange, {EndDate: Date(Year(ThisItem.Value),Month(ThisItem.Value),1)})
)

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

Thank you for your post, sorry of my late response.  I have been away.

I can't seem to get the date picker calendar to work using the one calendar.

Thank you for your time.

 

TB05
Helper III
Helper III

I think I may have more luck trying to use two date pickers.

I create two date pickers: daterangepicker1 and daterangepicker2.

On select, I have the following:

ClearCollect(
DateRange,
AddColumns(
FirstN(
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],
DateDiff(daterangepicker1.SelectedDate, daterangepicker2.SelectedDate, Days) + 1),
"Day",
"Day " & (Value + 1),
"Date",
DateAdd(daterangepicker1.SelectedDate, Value, Days)
)
)

 

So, I created a gallery so that I could see the dates in the collection and I have them all.  Now, I would like to update a SharePoint list with the individual dates in the collection.

When a user selects the range, then enters their time into a field, I would like the time to be Patched for each date in the collection.  

If I select, Dec 26 - Dec 31, I have 6 separate days to enter into a SharePoint list with the employees ID, time value and date.  I would think that I would have to use a ForAll function to loop through.  

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,245)