web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Datepicker latest date...
Power Apps
Answered

Datepicker latest date +1 day

(1) ShareShare
ReportReport
Posted on by 193

I have a SQL table containing a Date,

 

Now I want my datepicker to see what the latest date is in the table and then set the defaultdate + 1.

Categories:
I have the same question (0)
  • Verified answer
    Mike2500 Profile Picture
    1,247 Super User 2024 Season 1 on at

    Either of the following can be used to get the max date plus one day:

     

    DateAdd(Date(1970,1,1) + Max(datasource, datefield)/(60*60*24*1000),1,Days)

     

    DateAdd(First(Sort(datasource,datefield,Descending)).datefield,1,Days)

     

    Max isn't delegable, so perhaps stick with the second. Of course, either triggers a query to the database, so perhaps look into using collections, and then using the collection as the datasource.

     

    The first uses the max function, which doesn't return a date, but instead returns the value as the number of milliseconds since 1970, and then calculates the actual date value, and adds one day. The second retrieves the first row based on sorting the table by date, descending, and then adds one day. You can set either of the above as the default for the date picker.

     

     

  • Verified answer
    WarrenBelz Profile Picture
    156,384 Most Valuable Professional on at

    Hi @rvdhorst ,

    You could also do this and be completely Delegable (close to option #2 from @Mike2500)

    With(
     {
     wDates:
     Sort(
     YourTableName,
     YourDateField,
     Descending
     )
     },
     DateAdd(
     First(wDates).YourDateField,
     1,
     Days
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • rho1967 Profile Picture
    141 on at

    Thanks for the nice solutions.

    If the day+1 is a Sunday, how can I skip it to Monday (so +2)

  • Verified answer
    WarrenBelz Profile Picture
    156,384 Most Valuable Professional on at

    @rho1967 ,

    To skip to the next weekday

    With(
     {
     wDates:
     Sort(
     YourTableName,
     YourDateField,
     Descending
     )
     },
     DateAdd(
     First(wDates).YourDateField,
     Switch(
     Weekday(
     First(wDates).YourDateField
     ),
     6,
     3,
     7,
     2,
     1
     ),
     Days
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • rho1967 Profile Picture
    141 on at

    Sorry for the confusion. Below an example

     

    Monday+1

    Tuesday+1

    Wednesday+1

    Thursday+1

    Friday+1

    Saturday+2

     

    How can I make this jump? I was hoping to do a check on wDates.

  • Verified answer
    WarrenBelz Profile Picture
    156,384 Most Valuable Professional on at

    @rho1967 ,

    If Saturday is a Work day

    With(
     {
     wDates:
     Sort(
     YourTableName,
     YourDateField,
     Descending
     )
     },
     With(
     {wDay:First(wDates).YourDateField},
     DateAdd(
     wDay,
     If(
     Weekday(wDay) = 7,
     2,
     1
     ),
     Days
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • rho1967 Profile Picture
    141 on at

    hello warren,

     

    Sorry, but I'm getting an error. See Appendix.

    pic1.png
  • Verified answer
    WarrenBelz Profile Picture
    156,384 Most Valuable Professional on at

    @rho1967 ,

    Try small d in Weekday (corrected in post)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard