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 / How to compare now tim...
Power Apps
Answered

How to compare now time and DateTimeValue in IF statement?

(0) ShareShare
ReportReport
Posted on by 503

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. 

Categories:
I have the same question (0)
  • Verified answer
    StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    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

  • Usernametwice Profile Picture
    503 on at

    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 Profile Picture
    370 on at

    Hello,

     

    you could use "Not" ex:

    if(Not isBlank(), true, false)

     

    Hope this help,

    Regards.

  • Usernametwice Profile Picture
    503 on at

    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 Profile Picture
    Super User 2024 Season 1 on at

    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

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 294 Most Valuable Professional

#2
11manish Profile Picture

11manish 210

#3
Valantis Profile Picture

Valantis 169

Last 30 days Overall leaderboard