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

How to get hour & minutes from string and bind to date picker control

Team,

I am having text field in SharePoint list. In that the datetieme value is saved as string. For Ex. 7/22/2019 06:05.

I want to bind this value in date pciker control in power apps form.

 

I tried the below approach but it is not working properly if the time is less than 12 hours.

If(EditFormShiftDetails.Mode=FormMode.New,Hour(Now()),Text(Hour(DateTimeValue(DateText)),"[$-en-US]00"))

DateText is the internal field in SharePoint list. Please help me.

 

Thanks

Philip

18 REPLIES 18
Anonymous
Not applicable

Hi @Anonymous 

 

What values are pre populated in the dropdown.  e.g Is the "Items" property of the dropdown has values as: ["00","01","02","03","04","05"...]

 

To set default value, Text(DateTimeValue("7/22/2019 05:05"),"[$-en-US]hh") which would set the value to "05". 

 

Please note that if the value does not exist in the dropdown the first value is set

Anonymous
Not applicable

The below values are pre-populated in the items property.

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

Hi @Anonymous 

 

set default value of the dropdown control to:

 

Text(DateTimeValue("7/22/2019 05:05"),"[$-en-US]hh")  // consider only hh part of the datetime

 

Thanks.

Anonymous
Not applicable

Hi Shilendra,

It is not working any more for drop down controls.

Kindly let me know how can I use the split function to get the hour value.

I have used the below formula, but I get only minute value.

Last(LastN(Split(Datetext, ":"),1)).Result

How can I get the hour value?

Thanks

Philip

Anonymous
Not applicable

Hi @Anonymous 

 

First(Split(Last(Split("7/22/2019 05:05", " ")).Result, ":")).Result

 

Thanks.

Anonymous
Not applicable

Hi Shilendra,

The formula which you have given is working if we didn't check the condition whether the form mode is new or edit.

Please find the screenshot below and share me your inputs to resolve this issue.

Resulted ScreenShot

Split_Result.png

 

UnResulted Screenshot

Split_No_Result.png

 

Same scenario even before this formula applied.

I am in very much trouble. Please help me.

 

Anonymous
Not applicable

Hi @Anonymous 

 

You are setting the default value of dropdown with the same control default value.  The data should be based on the SharePoint List Column. check what is the datafield of the data card and you should consider Parent.Default or the column name itself.

 

Thanks. 

Anonymous
Not applicable

Hi Shilendra,

Even I tried the SharePoint List Column (Internal name of the field is "DateText"), but it is not working.

Split_No_Result_New.png

 

Please give me an idea. Thanks a lot for your support from morning onwards.

 

Anonymous
Not applicable

Hi Shilendra,

I just swap the if condition and it started working.

 

If(EditFormShiftDetails.Mode=FormMode.Edit, Text(Minute(DateTimeValue(DateText)),"[$-en-US]00"), Minute(Now()))

With Split function

 

If(EditFormShiftDetails.Mode=FormMode.Edit,Last(Split(Last(Split(DateText, " ")).Result, ":")).Result, Minute(Now()))

Thanks for your support.

 

Thanks

Philip

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 (2,460)