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

If function for date hour minute value

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!

2 ACCEPTED SOLUTIONS

Accepted Solutions

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

 

,
    Notify(""),
    Error
)



Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

View solution in original post

AJ_Z
Super User
Super User

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 🙂

 



Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

View solution in original post

12 REPLIES 12
AJ_Z
Super User
Super User

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
)



Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

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

 

,
    Notify(""),
    Error
)



Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

silviavg
Helper II
Helper II

It worked! thanks @AJ_Z 

silviavg
Helper II
Helper II

@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.

Glad I could help 🙂



Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

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

 



Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

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

silviavg_0-1655858311101.png

 

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




Signature:


If you appreciated my comments/responses please be sure to Like/Kudo them it really does make me smile 🙂 !
Link to the Power Platform Professionals United Kingdom User Group:

https://powerusers.microsoft.com/t5/Power-Platform-Professionals/gh-p/PowerPlatformProfessionalsUnit...

silviavg
Helper II
Helper II

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))

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

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.

<
Users online (2,430)