cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ThomasDeGreve
New Member

Hour( Now() ) returning 0 at certain times of the day.

First, I did not develop this PowerApp form, but I am trying to debug it because we are getting weird time data. I am just beginning to learn PowerApps.

 

My company uses sharepoint to track certain actions. When a user selects one of three values for a certain column it is supposed to record the date/hour/minute into a datetime column. The date seems to always be recorded properly, but between the hours of 1am and 11am the hour value always returns 0. After 11am everything seems to function properly and the correct time is recorded. This results in our reports showing a bunch of activity at 00:00 and then no activity until 11:00 after which the data looks normal. 

 

The default attribute for the HourValue on the card looks like this:

 

 

If(
    SharePointForm1.Mode = FormMode.Edit,
    If(
        And(
            Or(
                DataCardValue4.Selected.Value = "Selection 1",
                DataCardValue4.Selected.Value = "Selection 2",
                DataCardValue4.Selected.Value = "Selection 3"
            ),
            IsBlank(ThisItem.'Case File Completion Date')
        ),
        Hour(Now()),
        Text(Hour(Parent.Default),"[$-en-US]00")
    ),
    Text(Hour(Parent.Default),"[$-en-US]00")
)

 

 

My understanding is that if the field is blank and one of the three specified values has been selected on the form, the hour value should be set to Hour(Now()), meaning the current hour. I can't understand why this is only causing problems between 1am and 11am and works at all other times.

1 ACCEPTED SOLUTION

Accepted Solutions

HI @ThomasDeGreve ,

That is correct, but you do not need the nested If() statements - also the With() below is just to shorten the repetition. Also what result do you expect if the tests fail (are false)

With(
   {wSelect:DataCardValue4.Selected.Value},
   If(
      SharePointForm1.Mode = FormMode.Edit &&
      (
         wSelect = "Selection 1" ||
         wSelect = "Selection 2" ||
         wSelect = "Selection 3"
      ) &&
      IsBlank(ThisItem.'Case File Completion Date'),
      Text(
         Hour(Now()),
         "[$-en-US]00"
      )
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

5 REPLIES 5
GarethPrisk
Super User II
Super User II

Hour(Now()) should resolve correctly.

What is the field/control that you are setting this value into? Per that formula, you are resolving the value as two different data types.

  • Hour() would return a Number
  • Text(Hour()) would transform the value into text

This may be causing a conflict when the data is being written or formatted/used beyond the scope of the formula itself.

It may be as as simple as updating the formula to have a consistent output. Text(Hour(Now()))

Thank you for the response. I was unclear about this as well. It was my understanding that the If() function follows the format If(condition, result), but in this case there seems to be three parameters of the inner If() with the third being 

Text(Hour(Parent.Default),"[$-en-US]00")

 

I didn't want to start changing things until I understood why there are three parameters. The outer If() also has three. I took a stab at writing what I think it should be. Does this look correct or did I mess up some syntax?

 

If(
    SharePointForm1.Mode = FormMode.Edit,
    If(
        And(
            Or(
                DataCardValue4.Selected.Value = "Selection 1",
                DataCardValue4.Selected.Value = "Selection 2",
                DataCardValue4.Selected.Value = "Selection 3"
            ),
            IsBlank(ThisItem.'Case File Completion Date')
        ),
        Text(Hour(Now()),"[$-en-US]00")
    )
)

 

HI @ThomasDeGreve ,

That is correct, but you do not need the nested If() statements - also the With() below is just to shorten the repetition. Also what result do you expect if the tests fail (are false)

With(
   {wSelect:DataCardValue4.Selected.Value},
   If(
      SharePointForm1.Mode = FormMode.Edit &&
      (
         wSelect = "Selection 1" ||
         wSelect = "Selection 2" ||
         wSelect = "Selection 3"
      ) &&
      IsBlank(ThisItem.'Case File Completion Date'),
      Text(
         Hour(Now()),
         "[$-en-US]00"
      )
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

Hi @ThomasDeGreve ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Yes, I was able to get the form to function how I wanted using the code I posted, but I am still not sure why the old code had the odd behavior.

Helpful resources

Announcements
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (65,420)