Discussions

 View Only
Expand all | Collapse all

Setting a Field value based on a Date/Time Field

  • 1.  Setting a Field value based on a Date/Time Field

    Posted 05-20-2022 09:03
    I am trying to right a formula that will compare two Date/Time fields and set the text formula fields value based on the two values.  For example, if the first Date/Time field is set to "05-17-2022 12:00 AM" and the second Date/Time field is set to 05-17-2022 12:30 AM, I want the Formula Text field label to be set to "On time".  The rule for this value would be 30 minutes before and 30 minutes after the first Date/Time field.  If the second Date/Time field is outside of 30 minutes after the first Date/Time field, or more than 1/2 hour after, label should be "Late".

    Thanks


    ------------------------------
    Brian Dunk
    ------------------------------


  • 2.  RE: Setting a Field value based on a Date/Time Field

    Posted 05-20-2022 10:30
    Untested by try:

    If(
     [Date Time Field 2] > [Date Time Field 1] + minutes(30) or  [Date Time Field 2] < [Date Time Field 1] - minutes(30), "Late", "On time")

    ------------------------------
    Mike Tamoush
    ------------------------------



  • 3.  RE: Setting a Field value based on a Date/Time Field

    Posted 05-20-2022 11:51
    Thanks Mike,  that seems to work.  I thought I could get away with giving a subset of my formula and that would get me going.  That is not the case.  I should have presented all the rules initially as I seem to be getting boolean errors.  Here is a more clear definition of my labels
    "Pending" = Date/Time 2 blank and today is before Date/Time 1.
    "On Time" = Date/Time 2 is 30 minutes before or 30 minutes after Date/Time 1
    "Late" = Date/Time 2 is 30 minutes or more after Date/Time 1.
    "No Show" = Date/Time 2 is blank and today is after Date/Time 1.

    Thanks again!

    ------------------------------
    Brian Dunk
    ------------------------------



  • 4.  RE: Setting a Field value based on a Date/Time Field