cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Date picker not resetting

I am so close to finishing this app and I have learned so much! One last thing before my app is good to go. The app is a calculator to help staff plan out the dates for several committees. I've got date pickers to calculate the dates for the consequent meetings and the view-only deadline date pickers to calculate the memo deadline.

I have a reset button to clear out all the controls. The problem is that one date picker is not resetting to the default "12/31/2001" but to /1/1/1970 (Start of Year). I've tried adding another IF statement to it and it errors me out, and I've tried adding another logic statement to the existing If statements and it errors out too.  I think part of my problem is that I am using Default Date setting for the syntax so I've tried moving it to another setting and it doesn't like it.

Any help is appreciated.

 

ljkeefe_0-1632259345864.png

I have the following in the Default Date:

With({FirstOfMonth:Date(Year(COWDatePicker.SelectedDate),Month(COWDatePicker.SelectedDate),1),DayOfWeek:3,N:1},With({SecondTuesday:DateAdd(FirstOfMonth,(N * 7) - Weekday(DateAdd(FirstOfMonth,7-DayOfWeek)))},

With({SecondOfMonth:Date(Year(StudySessionDatePicker.SelectedDate),Month(StudySessionDatePicker.SelectedDate),1),DayOfWeekSS:3,NSS:2},With({SecondTuesSS:DateAdd(SecondOfMonth,(NSS*7)-Weekday(DateAdd(SecondOfMonth,7-DayOfWeekSS)))},With({FourthOfMonth:Date(Year(StudySessionDatePicker.SelectedDate),Month(StudySessionDatePicker.SelectedDate),1),DayofWeekFS:3,NFS:4},With({FourthTuesSS:DateAdd(FourthOfMonth,(NFS*7)-Weekday(DateAdd(FourthOfMonth,7-DayofWeekFS)))},

With({FirstOfMonthCC:Date(Year(StudySessionDatePicker.SelectedDate),Month(StudySessionDatePicker.SelectedDate),1),DayOfWeekCC:3,NCC:1},With({FirstTuesCC:DateAdd(FirstOfMonthCC,(NCC*7)-Weekday(DateAdd(FirstOfMonthCC,7-DayOfWeek)))},
With({ThirdOfMonth:Date(Year(StudySessionDatePicker.SelectedDate),Month(StudySessionDatePicker.SelectedDate),1),DayOfWeekSS3:3,N3SS:3},With({ThirdTuesSS:DateAdd(ThirdOfMonth,(N3SS*7)-Weekday(DateAdd(ThirdOfMonth,7-DayOfWeekSS3)))},

If(IsBlank(StudySessionDatePicker),DateAdd(DateAdd(FirstOfMonth,1,Months),(N*7)-Weekday(DateAdd(DateAdd(FirstOfMonth,1,Months),7-DayOfWeek))),

StudySessionDatePicker.SelectedDate=SecondTuesSS,DateAdd(DateAdd(FirstOfMonthCC,1,Months),(NCC*7)-Weekday(DateAdd(DateAdd(FirstOfMonthCC,1,Months),7-DayOfWeekCC))),

StudySessionDatePicker.SelectedDate=FourthTuesSS,DateAdd(DateAdd(ThirdOfMonth,1,Months),(N3SS*7)-Weekday(DateAdd(DateAdd(ThirdOfMonth,1,Months),7-DayOfWeekSS))),"")))))))))))

2 ACCEPTED SOLUTIONS

Accepted Solutions
StalinPonnusamy
Super User
Super User

 Hi @Anonymous 

 

Looks like still, this piece is missing. We need to Set OnChange property of the other Data Picker to 

UpdateContext({ResetDate:false});

 

When you are resetting Resetdate is true, Now we need to tell the system not to reset. So we have to add the above property on all of the Date picker on change property

View solution in original post

Anonymous
Not applicable

@StalinPonnusamy I got it! I researched in the community and someone suggested putting it in the OnSelect property of the control. I did that and it works!!! Thank you for all your help! This problem has been plaguing me for about two weeks now.

View solution in original post

9 REPLIES 9
StalinPonnusamy
Super User
Super User

Hi @Anonymous 

 

On the reset control Set

UpdateContext({ResetDate:true});Reset(DatePicker1)

 

Set the DefaultDate Property to

If(ResetDate,Blank(),Your Existing formula)

 

Note: Update your Date picker control, Add all controls if you have multiple.

Anonymous
Not applicable

@StalinPonnusamy 

Thank you for the response. When I insert what you suggested in the DefaultDate Property of my date picker, it does not respond to the dates entered in the other date picker. It's just blank, it's supposed to take the date from the other date picker field and calculate a future date. I inserted the formula at the beginning of my existing formula and it did not work, I also tried integrating it into my existing If statement and it did not work. 

StalinPonnusamy
Super User
Super User

Hi @Anonymous

 

I got it. We need to set the indicator to not reset when the other date picker changes.

 

Set OnChange property of the other Data Picker to 

 

UpdateContext({ResetDate:false});

 

 

On the reset control Set

UpdateContext({ResetDate:true});Reset(DatePicker1)

 

Set the DefaultDate Property to

If(ResetDate,Blank(),Your Existing formula)

 

Anonymous
Not applicable

@StalinPonnusamy Thank you for the response!

I tried it this way and the date picker doesn't calculate.

 

If(IsBlank(Datepicker3),DateAdd(DateAdd(FirstOfMonth,1,Months),(N*7)-Weekday(DateAdd(DateAdd(FirstOfMonth,1,Months),7-DayOfWeek))),

Datepicker3.SelectedDate=SecondTuesSS,DateAdd(DateAdd(FirstOfMonthCC,1,Months),(NCC*7)-Weekday(DateAdd(DateAdd(FirstOfMonthCC,1,Months),7-DayOfWeekCC))),

Datepicker3.SelectedDate=FourthTuesSS,DateAdd(DateAdd(ThirdOfMonth,1,Months),(N3SS*7)-Weekday(DateAdd(DateAdd(ThirdOfMonth,1,Months),7-DayOfWeekSS))),ResetDate,Blank())))))))))))

 

I tried this, 1/1/1970 still exists

 

If(IsBlank(DatePicker3),ResetDate,Blank(),DateAdd(DateAdd(FirstOfMonth,1,Months),(N*7)-Weekday(DateAdd(DateAdd(FirstOfMonth,1,Months),7-DayOfWeek))),

DatePicker3.SelectedDate=SecondTuesSS,DateAdd(DateAdd(FirstOfMonthCC,1,Months),(NCC*7)-Weekday(DateAdd(DateAdd(FirstOfMonthCC,1,Months),7-DayOfWeekCC))),

DatePicker3.SelectedDate=FourthTuesSS,DateAdd(DateAdd(ThirdOfMonth,1,Months),(N3SS*7)-Weekday(DateAdd(DateAdd(ThirdOfMonth,1,Months),7-DayOfWeekSS))))))))))))))

 

This one works but the user would have to click the reset button twice:

 

If(ResetDate,Blank(),If(IsBlank(DatePicker3),DateAdd(DateAdd(FirstOfMonth,1,Months),(N*7)-Weekday(DateAdd(DateAdd(FirstOfMonth,1,Months),7-DayOfWeek))),

DatePicker3.SelectedDate=SecondTuesSS,DateAdd(DateAdd(FirstOfMonthCC,1,Months),(NCC*7)-Weekday(DateAdd(DateAdd(FirstOfMonthCC,1,Months),7-DayOfWeekCC))),

DatePicker3.SelectedDate=FourthTuesSS,DateAdd(DateAdd(ThirdOfMonth,1,Months),(N3SS*7)-Weekday(DateAdd(DateAdd(ThirdOfMonth,1,Months),7-DayOfWeekSS)))))))))))))))

 

 

StalinPonnusamy
Super User
Super User

 Hi @Anonymous 

 

Looks like still, this piece is missing. We need to Set OnChange property of the other Data Picker to 

UpdateContext({ResetDate:false});

 

When you are resetting Resetdate is true, Now we need to tell the system not to reset. So we have to add the above property on all of the Date picker on change property

Anonymous
Not applicable

@StalinPonnusamy  Sorry, I didn't understand that the first time. I thought it was just the date picker that was responsible for the calculation. 

Ok, so I added the formula to the On Change property of all the date pickers, and it still does not work. I added the formula to the date picker that is not resetting as well and it glitches out. I'm sorry this is so problematic.

 

UpdateContext({ResetDate:false})

 

 

Anonymous
Not applicable

@StalinPonnusamy I got it! I researched in the community and someone suggested putting it in the OnSelect property of the control. I did that and it works!!! Thank you for all your help! This problem has been plaguing me for about two weeks now.

Anonymous
Not applicable

After testing the solution for some time I have come to find that it does not work. It makes the date picker unusable. Any other solutions out there?

Anonymous
Not applicable

After testing the solution for some time I have come to find that it does not work. It makes the date picker unusable. Any other solutions out there?

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (3,605)