Skip to main content
February 10, 2026
Question

Date time validation

  • February 10, 2026
  • 3 replies
  • 0 views

I have a requirement I have datetime component user can select the time maximum 2 hours from their current time else there should be validation error , i want to show the current time defaulted in the time field and they should select the time upto 2 hours . It should be in est . Can anyone help me with this 

    3 replies

    shubhama926776
    February 10, 2026

    Try this

    a!localVariables(
      local!selectedTime: now(),
      a!dateTimeField(
        label: "Select Time (max 2h from now)",
        value: local!selectedTime,
        saveInto: local!selectedTime,
        validations: (
          if(
            local!selectedTime > addhours(now(), 2),
            "Select time within 2 hours from current time",
            {}
          )
        )
      )
    )

    stefanhelzle0001
    February 10, 2026

    I suggest to use the a!addDateTime() function as it is included in the base product.