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

How to Show Date Picker Values in Edit Form

Hello Experts,

 

I am building an event app that allows you to add an event, view the event and edit the event.  When a new event is added, the user is able to set the date and time with a date picker.  However, if user goes to edit the event, the hour, minute and AM/PM values previously saved to SP and the gallery do not show up in the date picker.  Does anyone know how I can show the previously selected time in the date picker on the edit form?

 

Many thanks.

7 REPLIES 7
ZabiBabar
Continued Contributor
Continued Contributor

Hi @Anonymous If I am understanding correctly, you want to show the time of the event that you have opened in the edit mode. So If an event was added for June 6th 2020 5PM, when you open that event in edit mode it should still show June 6th 2020 5PM. If that is the case you should share what you are using for the default values for each of those inputs - Date, Hour, Minute, AM/PM.

 

I am using something very similar to you. I am assuming that you have a field 'Start Date' in your data source.  Let me show you what I have done. 

DefaultDate for Date Picker:

If(EventForm.Mode=FormMode.Edit, ThisItem.'Start Date', Now())

Default for HourDD_1:

If(
  EventForm.Mode=FormMode.Edit, 
  Text(Mod ( Hour( ThisItem.'Start Date' ), 12)), 
  Text(Mod ( Hour( Now() ), 12)), 
)

Default for MinuteDD_1:

If(
  EventForm.Mode=FormMode.Edit, 
  Text( Minute( ThisItem.'Start Date' ) ),
  Text( Minute( Now() ) )
)

 Default for AM_PMDD_1:

If(
  EventForm.Mode=FormMode.Edit, 
  If(Hour(ThisItem.'Start Date') < 12, "AM", "PM" ), 
  If(Hour(Now()) < 12, "AM", "PM" ), 
)

 

Best,
Zabi
Mark this post as a solution, or kudo it if you found it be helpful. You can choose more than multiple answers as solutions, including your own answer. 🙂

Anonymous
Not applicable

Hi @ZabiBabar ,

 

Thank you for the prompt response.  Yes, you are understanding perfectly what I wish to accomplish. 

 

I have used your suggestion and while the date and AM, PM values are correct.  The hour and minutes are at "12" and "00", still not showing the correct time of the event.

 

 

ZabiBabar
Continued Contributor
Continued Contributor

Can I see the items property of the Hours and Minutes dropdowns? In my case, I am storing a column that looks like this for minutes:

["1", "2", "3", ... "59", "60"]

 Looks very similar for hours as well.

 

But in your case, you might be storing numbers instead of strings. In that case, these might work:

If(
  EventForm.Mode=FormMode.Edit, 
  Mod ( Hour( ThisItem.'Start Date' ), 12), 
  Mod ( Hour( Now() ), 12), 
)
If(
  EventForm.Mode=FormMode.Edit, 
  Minute( ThisItem.'Start Date' ),
  Minute( Now() ) 
)

 

Best,
Zabi
Mark this post as a solution, or kudo it if you found it be helpful. You can choose more than multiple answers as solutions, including your own answer. 🙂

Anonymous
Not applicable

@ZabiBabar,

 

The Items property for my hour dropdown is

 

["12","01","02","03","04","05","06","07","08","09","10","11"]

 

The Items property for my minute dropdown is

 

["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"]

 

My SP list column is a date/time column.

 

 

ZabiBabar
Continued Contributor
Continued Contributor

Hi @Anonymous , Oh, I forgot to format the hour and minute to 2 digit numbers. After doing that it is working on my end as well. But I had to change it a little for the hour because 12PM was showing as 00AM. So there is the code for default property of Hour and Minute:

Hour:

 

If(
  EventForm.Mode=FormMode.Edit, 
  If(
    Mod(Hour(ThisItem.'Start Date'),12) = 0, 
    "12", 
    Text(Mod(Hour(ThisItem.'Start Date'),12),"[$-en-US]00")
  ),
  If(Mod(Hour(Now()),12) = 0, 
    "12", 
    Text(Mod(Hour(Now()),12),"[$-en-US]00")
  )
)

 

It Adds the 2 digit formatting and if the mod is 0, it converts it to 12, otherwise returns whatever the mod is.

Minute: 

 

If(
  EventForm.Mode=FormMode.Edit, 
  Text(Minute(ThisItem.'Start Date'), "[$-en-US]00"), 
  Text(Minute(Now()), "[$-en-US]00")
)

 

 

And the formula (I can see it in the screenshot) for your DataCard update is compatible with these jobs, so good job on that.

 

Best,
Zabi
Mark this post as a solution, or kudo it if you found it be helpful. You can choose more than multiple answers as solutions, including your own answer. 🙂

 

Anonymous
Not applicable

@ZabiBabar,

 

Yes, that did it!  All is working now.  Thank you! 

ZabiBabar
Continued Contributor
Continued Contributor

You are welcome! Please consider accepting an answer(s) as solutions so the item is closed and other people can see the solution as well. Thank you!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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