Forum Discussion

Re: Rounding Time to nearest quarter

try this

var datetime MidnightOfClockInDay = ToTimestamp(ToDate([Clock In Date Time]), ToTimeOfDay("12:00 am"));

var duration RoundedDuratonfromMidnight = Round([Clock In Date Time] - $MidnightOfClockInDay, Minutes(15));

ToTimeOfDay("12:00 am") + $RoundedDuratonfromMidnight

------------------------------
Mark Shnier (YQC)
Quick Base Solution Provider
Your Quick Base Coach
http://QuickBaseCoach.com
mark.shnier@gmail.com
------------------------------

4 Replies

  • WallaceYeboah's avatar
    WallaceYeboah
    Qrew Member
    Thanks for the response Mark! I'm still getting this error for the last line of code:


    "Expecting duration but found timeofday"

    ------------------------------
    Wallace Yeboah
    ------------------------------
  • WallaceYeboah's avatar
    WallaceYeboah
    Qrew Member
    Actually disregard that last message. Its working now. Thanks a lot!

    ------------------------------
    Wallace Yeboah
    ------------------------------
    • CourtneahThomas's avatar
      CourtneahThomas
      Qrew Trainee
      Wallace Yeboah,  how did you get it to work?  I am getting an error message on the last line that says "expecting text but found time of day"

      ------------------------------
      Courtneah Thomas
      ------------------------------
      • KevinHaigler's avatar
        KevinHaigler
        Qrew Member
        Hi Courtneah,

        the ToTimeOfDay function will convert the return to a time of day data type, if your formula is expecting text, then your field type is formula-text. You can either update this to Date/Time, or use one of the other conversion functions (ToText). Though I'm not sure what kind of display you'll get converting this to text.

        I'd recommend changing your field type to Date/Time or Duration depending on your use case.


        ------------------------------
        Kevin Haigler
        ------------------------------