Forum Discussion

KellyBianchi's avatar
KellyBianchi
Qrew Assistant Captain
6 years ago

Formula check box that is check during the hours of 8am-8pm Mon-Fri

I need a checkbox to help communicate the right message according to our hours of operation. Has anyone created anything like this?

------------------------------
Kelly
------------------------------
  • Kelly,

    You are going to have to play with the time variable based upon your time zone but this should do the trick.

    // Day Variable
    var number NumDay = DayOfWeek(Today());
    var bool MonToFri = Case($NumDay,
    0,false,
    1,true,
    2,true,
    3,true,
    4,true,
    5,true,
    6,false);

    // Time Variables
    var timeofday CurrentTime = ToTimeOfDay(Now());
    var bool EightToEight = If ( ToTimeOfDay("8:00AM")<$CurrentTime and ToTimeOfDay("8:00PM")<$CurrentTime,true, false );

    // Formula Check Box
    If ( $MonToFri=true and $EightToEight=true, true, false)

    ------------------------------
    Don Larson
    Paasporter
    Westlake OH
    ------------------------------
    • KellyBianchi's avatar
      KellyBianchi
      Qrew Assistant Captain
      Thanks, Don! I'll try this out and let you know =)





      ------Original Message------

      Kelly,

      You are going to have to play with the time variable based upon your time zone but this should do the trick.

      // Day Variable
      var number NumDay = DayOfWeek(Today());
      var bool MonToFri = Case($NumDay,
      0,false,
      1,true,
      2,true,
      3,true,
      4,true,
      5,true,
      6,false);

      // Time Variables
      var timeofday CurrentTime = ToTimeOfDay(Now());
      var bool EightToEight = If ( ToTimeOfDay("8:00AM")<$CurrentTime and ToTimeOfDay("8:00PM")<$CurrentTime,true, false );

      // Formula Check Box
      If ( $MonToFri=true and $EightToEight=true, true, false)

      ------------------------------
      Don Larson
      Paasporter
      Westlake OH
      ------------------------------
      • DonLarson's avatar
        DonLarson
        Qrew Elite
        Kelly,

        I made a mistake in the variable EightToEight.   The second half had 8PM being before the Current Time.  Here is the simple correction.

        var bool EightToEight = If ( ToTimeOfDay("8:00AM")<$CurrentTime and $CurrentTime< ToTimeOfDay("8:00PM"),true, false );

        ------------------------------
        Don Larson
        Paasporter
        Westlake OH
        ------------------------------