Converting a 24 Hour Dropdown to a 12 Hour AM/PM Drop Down

1. Update the properties in your Hour dropdown to the following

Items

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

Default

Text(If(Mod(Hour(Parent.Default), 12) = 0, 12, Mod(Hour(Parent.Default), 12)),"00")  
JavaScript
2. Add a new Dropdown and let’s name it dropDownAMPM

Items

["AM", "PM"]
JavaScript

Defaults

If(Hour(Parent.Default) < 12, "AM", "PM")
JavaScript
3. Update Property of the DataCard of your patch

If you need to submit it with only Time Value

Time(
  If(dropDownAMPM.Selected.Value = "PM", 12, 0) 
  + Mod(Value(dropDownHour.Selected.Value), 12), Value(dropDownMinute.Selected.Value), 0)
JavaScript

If you need to submit it with a Date Value

DatePicker1.SelectedDate + 
Time(
  If(dropDownAMPM.Selected.Value = "PM", 12, 0) 
  + Mod(Value(dropDownHour.Selected.Value), 12), Value(dropDownMinute.Selected.Value), 0)
JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *