cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Emont
Helper II
Helper II

Work with date and time

Hello, I hope everybody here are fine.

 

Currently, I have a delivery date fields as follows:

 

Emont_0-1634086733615.png

The idea here is not to allow to select an old datetime and not less than 4 hours, for example, if the service is requested for today 12/10/2021 at 11 am, the time could not be 11:30 but >= to 4 hours (15:30), how to do this?

 

Thanks in advance for the assistance.

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Super User
Super User

Hi @Emont

 

I made a working sample the same with the form and here is the user to force to select the correct date and time.

 

StalinPonnusamy_0-1634127612893.png

 

View solution in original post

3 REPLIES 3
StalinPonnusamy
Super User
Super User

Hi @Emont 

 

We can't force the Calendar not to select but we can validate when the user selected while saving. The below code gives true or false based on the date selection

DateDiff(
    DateTimeValue(
        StartDatePicker7.SelectedDate & " " & TimeValue(
            Concatenate(
                StartHourDropdown.Selected.Value,
                ":",
                StartMinutesDropdown.Selected.Value
            )
        )
    ),
    Now(),
    Minutes
) < 240

 

Example

StalinPonnusamy_0-1634088426111.png

On from save we can validate the user input and allow them to save. Below code can be used on Save button click 

If(DateDiff(
    DateTimeValue(
        StartDatePicker7.SelectedDate & " " & TimeValue(
            Concatenate(
                StartHourDropdown.Selected.Value,
                ":",
                StartMinutesDropdown.Selected.Value
            )
        )
    ),
    Now(),
    Minutes
) < 240,
SubmitForm(EditForm),
Notify("Selected Date Can't be less than 4 hours"))

 

StalinPonnusamy
Super User
Super User

Hi @Emont

 

I made a working sample the same with the form and here is the user to force to select the correct date and time.

 

StalinPonnusamy_0-1634127612893.png

 

Thank you so much @StalinPonnusamy, you are awesome!!!!!!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

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.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,369)