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

Date, hour, minute picker current date, hour, and minute

 

The first part of this Text(Hour...) corresponds to a dropdown box to pick the current hour
The 2nd part of all the #'s is to pick the minutes

 

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

["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"]


The last part is selecting my date (which will just choose off of the last linked event I choose) 

BrowseGallery1.Selected.EventDate


What I am trying to do, is make the date picker to always show the current date, and have the hour and minute box show the current time, but still allow choosing any number.

image.png

 

 

3 ACCEPTED SOLUTIONS

Accepted Solutions

You can change the Default property of the card (the card that holds the value, not the individual controls) so that if the value is null (which is the case for new items) then it will use the current time instead.

Coalesce(ThisItem.<dateTimeFieldName>, Now())

Notice that if this field can have null values already stored, then you may overwrite them if you use the expression above. Another alternative is to check the form mode, and if it's in the "NewForm" mode (creating a new item), then use the current date/time like shown below.

If(
EditForm1.Mode = FormMode.New,
Now(),
ThisItem.<dateTimeFieldName>)

View solution in original post

@PK_Hong 

Under the drop down control (advanced tab) I've used the following for hour, and left the function line with the standard [00-23] as previously mentioned. - This is working fine.

Text(Now(), "[$-en-US]hh")

 

 

However, on the minute one (using the same method and the [00-59]) It seems to be stuck at the default time for the minutes being at 08

Text(Now(), "[$-en-US]mm")

Any ideas?

View solution in original post

Hi @xerxes2985

 

My correction as I am also unaware of the limitation.

Anyway, just use Right() function.

 

Right(Text(Now(), "[$-en-US]hh:mm"), 2),..., to extract right side of hh:mm, to be "mm"

 

Please refer to documentation:

> The m or the mm placeholder must appear immediately after the h or hh placeholder or immediately before the ss placeholder. Otherwise, Text returns the month instead of minutes.

 

Have a nice day

View solution in original post

8 REPLIES 8
bdodu
Responsive Resident
Responsive Resident

And how is this different from the standard implementation of a DateValue DataCard ?

xerxes2985
Frequent Visitor

The default is blank. I want it to show the current hour, and I want the date to show the current date, and then let you choose other dates.

You can change the Default property of the card (the card that holds the value, not the individual controls) so that if the value is null (which is the case for new items) then it will use the current time instead.

Coalesce(ThisItem.<dateTimeFieldName>, Now())

Notice that if this field can have null values already stored, then you may overwrite them if you use the expression above. Another alternative is to check the form mode, and if it's in the "NewForm" mode (creating a new item), then use the current date/time like shown below.

If(
EditForm1.Mode = FormMode.New,
Now(),
ThisItem.<dateTimeFieldName>)

Sorry for such a delayed response. The first method you provided works fine for the calendar date as a starting and endpoint. Thanks!

Coalesce(ThisItem.EventDate, Now())

 

However, I can't seem to figure out how to apply the same concept to the hour / minute picker. Here is the default code that is in the app:

 

Hour drop down

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

Minute drop down

["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"]

It works to be able to choose what time just fine, but how would I make it so it reflects the current time (as a starting point to choose from)? I've attached a screen capture. Also, there is not a corresponding data card to the drop down lists for hour/minute.

 

Hi @xerxes2985

 

For Dropdown, you may alwasy use "Default" value and refer to current time.

eg.: Dropdown.Default = Text(Now(), "hh") for hour, and "mm" for min)

 

Hope this helps.

 

Have a nice day.

@PK_Hong 

Under the drop down control (advanced tab) I've used the following for hour, and left the function line with the standard [00-23] as previously mentioned. - This is working fine.

Text(Now(), "[$-en-US]hh")

 

 

However, on the minute one (using the same method and the [00-59]) It seems to be stuck at the default time for the minutes being at 08

Text(Now(), "[$-en-US]mm")

Any ideas?

Hi @xerxes2985

 

My correction as I am also unaware of the limitation.

Anyway, just use Right() function.

 

Right(Text(Now(), "[$-en-US]hh:mm"), 2),..., to extract right side of hh:mm, to be "mm"

 

Please refer to documentation:

> The m or the mm placeholder must appear immediately after the h or hh placeholder or immediately before the ss placeholder. Otherwise, Text returns the month instead of minutes.

 

Have a nice day


@PK_Hong wrote:

Hi @xerxes2985

 

My correction as I am also unaware of the limitation.

Anyway, just use Right() function.

 

Right(Text(Now(), "[$-en-US]hh:mm"), 2),..., to extract right side of hh:mm, to be "mm"

 

Please refer to documentation:

> The m or the mm placeholder must appear immediately after the h or hh placeholder or immediately before the ss placeholder. Otherwise, Text returns the month instead of minutes.

 

Have a nice day


I was fumbling for sometime before I found this post about the mm needing the hh - thank you very much!

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,150)