cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Andries
Frequent Visitor

Functions for code

Good Day i copied some code from a site and it does what I want to a extent. The code generates a calendar and lowers days to be selected and provides a summery Date to Date I want to change the code to exclude weekends from the selection.

 

 

Code : If(!_initialized, UpdateContext({_today:Today()}); UpdateContext({_firstDayOfMonth:DateAdd(_today,1-Day(_today),Days)}); UpdateContext({_firstDayInView:DateAdd(_firstDayOfMonth,-(Mod(Weekday(_firstDayOfMonth)-2,7)+1),Days)}); UpdateContext({_holidays:Table({HolidayDate:Date(2016,12,25)}, {HolidayDate:Date(2017,1,1)}, {HolidayDate:Date(2017,1,16)}, {HolidayDate:Date(2017,2,20)}, {HolidayDate:Date(2017,5,29)}, {HolidayDate:Date(2017,7,4)}, {HolidayDate:Date(2017,9,4)}, {HolidayDate:Date(2017,11,23)}, {HolidayDate:Date(2017,11,24)}, {HolidayDate:Date(2017,12,25)} ) }); UpdateContext({_initialized:true}) )

 

 

Output button : If( _selectedCount = 1, Text(_selectionStart, DateTimeFormat.ShortDate), _selectedCount = 2, Text(_selectionStart, DateTimeFormat.ShortDate) & " - " & Text(_selectionEnd, DateTimeFormat.ShortDate), "none")

 

 

Now my problem is I am pretty bad on the code side and I have no idea what to do. If I can get guidance on maybe how to fix my issue and maybe more important to my long term ability to use/read/employ code.

1 ACCEPTED SOLUTION

Accepted Solutions
v-zhta-msft
Resolver II
Resolver II

Hi @Andries

 

Could you please share more information about your issue especially the mean of “exclude”?

 

Do you want to make the weekends differ from the weekday like using different color?

 

Or do you want to hide the weekends column in you selection?

 

If you just want to make the weekends differ from the weekday like using different circle.

 

Here is the workaround:

 

Change “DaySelectedCircle”  formula as below:

 

8_24.png

RGAB(47,41,43,41) represents the black circle and RGBA(48,128,255,1) represents the blue circle.

 

You can change the color whatever you like.

 

Here are the links about function RGBA() and Weekday():

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-colors

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-datetime-parts

 

Then you can exclude the weekends with black circle:

2018_8_24_11.png

 

 

Hope this helps you.

 

Best regards,

Zhen

 

 

 

View solution in original post

1 REPLY 1
v-zhta-msft
Resolver II
Resolver II

Hi @Andries

 

Could you please share more information about your issue especially the mean of “exclude”?

 

Do you want to make the weekends differ from the weekday like using different color?

 

Or do you want to hide the weekends column in you selection?

 

If you just want to make the weekends differ from the weekday like using different circle.

 

Here is the workaround:

 

Change “DaySelectedCircle”  formula as below:

 

8_24.png

RGAB(47,41,43,41) represents the black circle and RGBA(48,128,255,1) represents the blue circle.

 

You can change the color whatever you like.

 

Here are the links about function RGBA() and Weekday():

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-colors

 

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-datetime-parts

 

Then you can exclude the weekends with black circle:

2018_8_24_11.png

 

 

Hope this helps you.

 

Best regards,

Zhen

 

 

 

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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