cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Problems with displaying Time from dropdowns

Hello,

 

I created some dropdowns for choosing a time. The initial idea was to calculate the difference between END & Start time, which would then give a precise time.

The dropdowns look like this:

Screenshot 2021-05-01 122814.png

So we have 4 dropdowns in total: (from left to right) "HourValueStart", "MinuteValueStart", "HourValueEnd", "MinuteValueEnd"

I tried following code first:

 

Text(Time(
    Value(HourValueEnd.Selected.Value) - Value(HourValueStart.Selected.Value);
    Value(MinuteValueEnd.Selected.Value) - Value(MinuteValueStart.Selected.Value);
    0))

 

but once I want to submit this, it returns an error saying "Invalid value '1619823600000' for field 'Einsatzzeit', expected a string".

 

Then I tried something else:

 

HourValueStart.Selected.Value & ":" & MinuteValueStart.Selected.Value & " - " & HourValueEnd.Selected.Value & ":" & MinuteValueEnd.Selected.Value 

 

with the goal to display exactly what was given as input. In this case it would have been "06:00 - 07:00". When I submit and go to check, it is just blank. In the spreadsheet (where it is stored once we hit the submit button) the column "Einsatzzeit" is also blank.

Anyone an idea what the issue could be?

11 REPLIES 11
Anonymous
Not applicable

Hi @Anonymous  - I have a sneaking suspcicion that those drop down controls are on a form that is in edit mode?

I could be completely wrong, but when I went to generate the dropdowns from an Excel table, by adding an Edit Form and specifying the table as the data source and finally adding in the two date columns in the table. If you were to play or just see the results everything was blank.

 

The penny then dropped when I realised of course it will be blank because I am in the edit mode of the form, without being in the context of an item within the data source. So this would work if we referenced a row in the excel spreadsheet for example.

 

However I was not bothered about that due to just wanting to set something up to provide you with some advice, so I just went to the form and set it to New mode and I now have the following results.

The first label is using your code.

 

Then second is doing Date Diff.

 

The final is just me sanity checking that I can surface one of the hour values.

 

HenryARPhillips_0-1619888644475.png

Or you could probably just specify an item by doing something like 

HenryARPhillips_1-1619888815738.png

Or if you don't want the form and be able to switch between new entries and edit entries. Maybe just copy the controls out of the form and use them independently.

 

Thanks

 

Henry

 

WarrenBelz
Super User
Super User

Hi @Anonymous ,
See below - you need ; instead of , for your region, but this produces the result you require

TimeDiff.png

 

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.

Anonymous
Not applicable

Hi @WarrenBelz . I tried the suggested change, but it still returns an error saying "Invalid value '1619823600000' for field 'Einsatzzeit', expected a string".

@Anonymous ,

What are the Items and Default of your drop-downs and are they drop-down or combo box controls?

Anonymous
Not applicable

@WarrenBelz,

 

The Items of the drop-downs are like this:

 

["00";"01";"02";"03";"04";"05";"06";"07";"08";"09";"10";"11";"12";"13";"14";"15";"16";"17";"18";"19";"20";"21";"22";"23"]

 

and the Default is like this:

 

Text(Hour(Parent.Default);"00")

(obviously for minute it is "Text(Minute(Parent.Default);"00")"

 

Those are drop-downs and not combo box controls.

Screenshot 2021-05-03 120148.png

 

Thanks @Anonymous ,

I was hoping for something different there to explain the error, but they are standard items generated by Power Apps. Have another look at the post I made earlier which was on a label and duplicate it (with your regional syntax) and see if you get an error (as it works perfectly here).

Also, what type of field is  'Einsatzzeit'

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.

Anonymous
Not applicable

@WarrenBelz,

 

I did the test with a label, and it works there:

 

Screenshot 2021-05-04 134726.png

So it shows no error. 'Einsatzzeit' is of type 'DateTime', if that's what you're asking.

Anonymous
Not applicable

@WarrenBelz,

 

I formatted the column 'Einsatzzeit' to Time. Then, I removed the 'Text()' function, such that a result of type 'Time' is returned. Then I got a result in following format: "dd.mm.yyyy hh:mm" Afterwards I re-added the 'Text()' function to the code and used some concatenation to only display time and now it works for some reason?

 

The only issue that remains is, that in the spreadsheet, it still stores the result as "dd.mm.yyyy hh:mm". How can I store only "hh:mm" ?

 

 

Anonymous
Not applicable

The solution was to change the datatype to Text and just display plain text instead of DateTime. What I am currently trying to find out is, how to set the default values of each dropdown control such that, when the user is editing, that it doesn't reset to 00, but remains the value it was upon creation...

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Solution Authors
Top Kudoed Authors
Users online (2,126)