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 / If function for date h...
Power Apps
Answered

If function for date hour minute value

(2) ShareShare
ReportReport
Posted on by 86

Hi!

 

I need to condition a date&hour field in my canvas app according to another date of the form. I have two date & hour field, one called "Recolección cliente origen" and the other one called "Entrega cliente destino", what I need is to build a formula that does not allow the user to enter a date & hour in "Entrega cliente destino" less that "recolección cliente origen" date & hour. The formula I have right now is validating only the date but I need it to validate hour and minutes. how should I do it?

silviavg_0-1655855414567.png

Thanks in advance for helping!

Categories:
  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Try this:

    If(
     Or(
     (DateValue1.SelectedDate + Time(
     Value(HourValue1.Selected.Value),
     Value(MinuteValue1.Selected.Value),
     0
     )) < Today(),
     (DateValue2.SelectedDate + Time(
     Value(HourValue2.Selected.Value),
     Value(MinuteValue2.Selected.Value),
     0
     )) < (DateValue1.SelectedDate + Time(
     Value(HourValue1.Selected.Value),
     Value(MinuteValue1.Selected.Value),
     0
     ))
     ),
     Notify(""),
     Error
    )
  • Verified answer
    AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Don't forget to change the if true and else notify bit at the end to what you want it to be:

     

    ,
     Notify(""),
     Error
    )
  • silviavg Profile Picture
    86 on at

    It worked! thanks @AJ_Z 

  • silviavg Profile Picture
    86 on at

    @AJ_Z do you know how can I do to don't allow the user to send the form? actually we are only notifying him but I want to don't allow him to send the request if the date is wrong.

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Glad I could help 🙂

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Ofcourse how are you submitting the form? is it with a button if so we can change the displaymode?

     

  • silviavg Profile Picture
    86 on at

    Yes, I already have this formula in the button. How can I add the new one? 

    silviavg_0-1655858311101.png

     

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Would you be able to Paste both of your formulas in so I can copy it easily 🙂 and give you the combined formula


  • silviavg Profile Picture
    86 on at

    Set(DateVar,DateValue2.SelectedDate + 30); If(DataCardValue10_1>DateVar,Notify("El tiempo de duración de jornada no puede ser mayor a 30 días",NotificationType.Error),SubmitForm(EditForm1_1))

  • Verified answer
    AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    Here is the formula below added to the one you already did 🙂

     

    Set(
     DateVar,
     DateValue2.SelectedDate + 30
    );
    If(
     DataCardValue10_1 > DateVar,
     Notify(
     "El tiempo de duración de jornada no puede ser mayor a 30 días",
     NotificationType.Error
     ),
     Or(
     (DateValue1.SelectedDate + Time(
     Value(HourValue1.Selected.Value),
     Value(MinuteValue1.Selected.Value),
     0
     )) < Today(),
     (DateValue2.SelectedDate + Time(
     Value(HourValue2.Selected.Value),
     Value(MinuteValue2.Selected.Value),
     0
     )) < (DateValue1.SelectedDate + Time(
     Value(HourValue1.Selected.Value),
     Value(MinuteValue1.Selected.Value),
     0
     ))
     ),
     Notify(
     "No Puedo...",
     NotificationType.Error
     ),
     SubmitForm(EditForm1_1)
    )

    change "No Puedo" to the full error message you wanted.

     

    also just looking at your first condition:

    DataCardValue10_1 > DateVar

     

    I am not sure what DataCardValue10_1 is but if it is working and correct no worries I am leaving that part the same then 🙂

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 225

#3
M Bilal Khan Profile Picture

M Bilal Khan 192

Last 30 days Overall leaderboard