cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Usernametwice23
Helper V
Helper V

How to compare now time and DateTimeValue in IF statement?

Hi all 

 

I have created an IF statement inside a collect which posts to dataverse as you can see below: 

Collect(
    'Time',
    {
        'Code': TextInputCode.Text,
        'Login Time': If(IsBlank(DefaultStartTime7am),Now();DateTimeValue("7:00 AM")),

    }
);

So if the label is blank then it will create a now() time for certain users while if not blank, it will say that the user started at 7am. 

 

I am trying to now figure out how I can add into this statement that if the user with a non blank label signs in past 7am, it will be recorded as now() instead of 7am. Im unsure how to add this into the syntax if someone could help me write this out. I have a feeling I would need to use greater or less than signs to accomplish this. 

 

Thanks so much for the help. Kind regards. 

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Super User
Super User

Hi @Usernametwice23 

 

Please try this

Collect(
    'Time',
    {
        'Code': TextInputCode.Text,
        'Login Time': If(IsBlank(DefaultStartTime7am) || (Now() > DateTimeValue("7:00 AM")),Now(),DateTimeValue("7:00 AM"))

    }
);

 
Thanks,
Stalin - Learn To Illuminate

View solution in original post

5 REPLIES 5
StalinPonnusamy
Super User
Super User

Hi @Usernametwice23 

 

Please try this

Collect(
    'Time',
    {
        'Code': TextInputCode.Text,
        'Login Time': If(IsBlank(DefaultStartTime7am) || (Now() > DateTimeValue("7:00 AM")),Now(),DateTimeValue("7:00 AM"))

    }
);

 
Thanks,
Stalin - Learn To Illuminate

Hi @StalinPonnusamy Thank you for your help. 

It seems to be stuck on the now() time. So it wont recognize that the current time is less than the DateTimeValue and keeps recording as now() when its meant to round up to 7am. 

'Login Time': If((DefaultStartTime7am.Text="Yes") || (Now() > DateTimeValue("7:00 AM")),Now(),DateTimeValue("7:00 AM"))

Thanks again for your help. 

 

AmeerJab
Resolver I
Resolver I

Hello,

 

you could use "Not" ex:

if(Not isBlank(), true, false)

 

Hope this help,

Regards.

Usernametwice23
Helper V
Helper V

Hi @AmeerJab  Thanks for your suggestion. 

 

'Login Time': If(IsBlank(DefaultStartTime7am.Text="Yes") || (Now() > DateTimeValue("7:00 AM")),Now(),DateTimeValue("7:00 AM"))

This works but I need to filter if the DefaultStartTime7am.Text="Yes" , so if it = "No" then the time should be now() instead of 7am  

StalinPonnusamy
Super User
Super User

Hi @Usernametwice23 

 

Looks like 7 AM should be

  1. When DefaultStart time is Yes
  2. If anyone logins before 7 AM

All other times should be the current time. 

 

If(DefaultStartTime7am.Text="Yes" || Now() < DateTimeValue("7:00 AM"),DateTimeValue("7:00 AM"),Now())

 

DefaultStartTime7am is a boolean field or Text field?


Thanks,
Stalin - Learn To Illuminate

Helpful resources

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

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,209)