web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Very complicated Time ...
Power Apps
Unanswered

Very complicated Time Start/End Form

(1) ShareShare
ReportReport
Posted on by 356

I am trying to minimize data entry time on my intervention form so I would like to automate as much as possible.

 

I have a StartTime Card and an EndTime Card that have 3 dropdowns: Hour, Minute, and AM/PM.

 

StartTime Card:

ddStartTimeHour

ddStartTimeMinute

ddStartTimeAMPM

 

EndTime Card:

ddEndTimeHour

ddEndTimeMinute

ddEndTimeAMPM

 

I need to set default on my ddStartTimeHour for current hour but user can change with dropdown if contact made was not within the current hour.

 

ddStartTimeHour

Items: ["12","1","2","3","4","5","6","7","8","9","10","11"]

 

 Likewise, I need to set default on my ddStartTimeMinute for current minute as close to the 5 minute interval listed in items, also user can change with dropdown if contact made was not within the current minute.

 

ddStartTimeMinute

Items: ["05", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55"]

 

Finally, need to set ddStartTimeAMPM to current AM/PM

ddStartTimeAMPM

Items: ["AM", "PM"]

 

Now the tricky part:

Want EndTime default hour, minute, AM/PM, dropdown values to be based on ddContactType_1.Selected.Value

 

ddContactType_1 Items:

["CICO", "Student Conference", "Guardian Conference", "Phone", "Home Visit", "Text Message", "Letter", "Email"]

 

"CICO" End time = start time +15 minutes 

"Student Conference" End time = start time + 30 minutes

"Guardian Conference" End time + 30 minutes

"Phone" End time = start time + 5 minutes 

"Home Visit" End time = start time + 30 minutes

"Text Message" End time = start time+ 5 minutes

"Letter" End time + 10 minutes

"Email" End time + 5 minutes

 

Need this to be displayed in EndTime card dropdowns:

ddEndTimeHour

ddEndTimeMinute

ddEndTimeAMPM

 

For example, if start time of CICO was 7:15am, then 

ddEndTimeHour default would be 7

ddEndTimeMinute default would be 30, 

ddEndTimeAMPM default would still be AM

 

Maybe I am outkicking my coverage but if I can get this to work, my users and I will be very grateful.

Categories:
I have the same question (0)
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @slhangen 

     

    This is indeed a challenging scenario, but it's not beyond reach.

    Power Apps should be able to handle this quite well with some creative formula solutions.

    The main functions you can try to use here are Text, Now, and Switch.

    Also, for simplicity, you can calculate a new DateTime with minutes added.

    Once you have a DateTime value, you can then extract hours, minutes, and AM/PM from it easily.

    First, you can try and tackle the ddStartTimeHour, ddStartTimeMinute, and ddStartTimeAMPM. These dropdowns should be populated with current time values by default.

     

    For ddStartTimeHour in the Default property, try to use this formula:

    Text(Now(), "hh")

     

    For ddStartTimeMinute, to round it to the nearest 5 minutes interval:

    Text(Round(Time(Minute(Now()), 0, 0)/300, 0)*5, "00")

     

    For ddStartTimeAMPM, in the Default property:

    Text(Now(), "AM/PM")

     

    Now you could try to calculate the End Time based on selected Contact Type. 

    For this, you can first calculate a new DateTime based on added minutes:

    Set(
    varEndTime,
    DateAdd(
    Time(
    Value(ddStartTimeHour.Selected.Value),
    Value(ddStartTimeMinute.Selected.Value),
    If(ddStartTimeAMPM.Selected.Value="AM",0,12)
    ),
    Switch(
    ddContactType_1.Selected.Value,
    "CICO", 15,
    "Student Conference", 30,
    "Guardian Conference", 30,
    "Phone", 5,
    "Home Visit", 30,
    "Text Message", 5,
    "Letter", 10,
    "Email", 5
    ),
    Minutes
    )
    )

     

    Then you can extract hours, minutes and AM/PM from varEndTime to populate ddEndTimeHour, ddEndTimeMinute, and ddEndTimeAMPM.

     

    For ddEndTimeHour in the Default property:

    Text(varEndTime, "hh")

     

    For ddEndTimeMinute in the Default property:

    Text(varEndTime, "nn")

     

    For ddEndTimeAMPM and in the Default property:

    Text(varEndTime, "AM/PM")

     

    Note: These formulas assume you've created a variable varEndTime to store the calculated EndTime.

    Remember to adjust these formulas based on your application scenario..

     

    See if this helps @slhangen

  • slhangen Profile Picture
    356 on at

    Getting error from:

    OnChange from ddContactType_1

    Set(
    varEndTime,
    DateAdd(
    Time(
    Value(ddStartTimeHour.Selected.Value),
    Value(ddStartTimeMinute.Selected.Value),

    If(ddStartTimeAMPM.Selected.Value="AM",0,12)
    ),
    Switch
    (
    ddContactType_1.Selected.Value,
    "CICO", 15,
    "Student Conference", 30,
    "Guardian Conference", 30,
    "Phone", 5,
    "Home Visit", 30,
    "Text Message", 5,
    "Letter", 10,
    "Email", 5
    ),
    Minutes
    )
    )

     

    slhangen_0-1690995939806.pngslhangen_1-1690995962348.png

     

  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @slhangen 
    Sorry, it was my mistake, I believe Power Apps sometimes cannot infer the shorthand in some cases. I almost swear it was working before with the inference in the past, but it could just be my mistake.
    Can you try explicitly specifying TimeUnit.Minutes instead of Minutes and see if it helps? 
    See below:

    Set(
     varEndTime,
     DateAdd(
     Time(
     Value(ddStartTimeHour.Selected.Value),
     Value(ddStartTimeMinute.Selected.Value),
     If(ddStartTimeAMPM.Selected.Value="AM",0,12)
     ),
     Switch
     (
     ddContactType_1.Selected.Value,
     "CICO", 15,
     "Student Conference", 30,
     "Guardian Conference", 30,
     "Phone", 5,
     "Home Visit", 30,
     "Text Message", 5,
     "Letter", 10,
     "Email", 5
     ),
     TimeUnit.Minutes
     )
    )

    Tell me if it helps @slhangen 

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 977

#2
Valantis Profile Picture

Valantis 664

#3
11manish Profile Picture

11manish 530

Last 30 days Overall leaderboard