cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mjdacs
Frequent Visitor

DateDiff()

Hello All,

Before submitting a form I am trying to set a time condition that the end time of the task is not before the start time. I can verify that the DateDiff() formula below does produce a negative value if endTime < startTime. However when the logic evaluates to true, the form is still submitted.

Here's the code:

 

If(
    DateDiff(startTime, endTime, Seconds) < 0,
    LabelForTimeError.Text = "TIME IS WRONG!",
    SubmitForm(SweepForm)
);


Your help is greatly appreciated!

 

1 ACCEPTED SOLUTION

Accepted Solutions
mjdacs
Frequent Visitor

It was a bug in my code. My understanding of the scoping in PowerApps is not there. I left a Navigate function outside the If statement, and no matter what happened in the conditional, the Navigate function ultimately is called.

View solution in original post

3 REPLIES 3
eka24
Super User III
Super User III

A little clarification, is starttime and endtime variables or DatePicker or from a column. If variable, can you show the formula

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

mjdacs
Frequent Visitor

startTime and endTime are local variables defined by Now() in their respective buttons.

 

UpdateContext({endTime: Now()})

 

 

mjdacs
Frequent Visitor

It was a bug in my code. My understanding of the scoping in PowerApps is not there. I left a Navigate function outside the If statement, and no matter what happened in the conditional, the Navigate function ultimately is called.

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (3,232)