Discussions

Expand all | Collapse all

Using Variables in Formulas

Jump to Best Answer
  • 1.  Using Variables in Formulas

    Posted 02-11-2020 10:06

    Hello all,

    I'm trying to create a formula checkbox to check off between two hardcoded dates/times each month.

    My current formula looks like this:
    var DateTime FebPRStart = DateTime(02-01-2020 12:00 AM);
    var DateTime FebPREnd = DateTime(02-15-2020 11:59 PM);
    var Bool FebCalc = Today()>=$FebPRStart and Today()<=$FebPREnd;

    Case
    (Month(Today()) = 2,$FebCalc,true,false,

    My problem is with the orange highlighted text. I was able to use the date variable when I started, but it seems like I cannot use the datetime the way I'm approaching it.

    Does anyone have any ideas on how to include time in my variables and streamlining my formula in case I'm overcomplicating it.

    Thanks for any help you can provide.



  • 2.  RE: Using Variables in Formulas

    Posted 02-11-2020 11:11
    Uchenna,

    Today() is a date
    Now() will give you a Date Time

    I think the issue is your BOOL.  Use Now() instead of Today()


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



  • 3.  RE: Using Variables in Formulas

    Posted 02-11-2020 15:44
    Thanks for your response. It helped to point me in the right direction.

    ------------------------------
    Uchenna Ogbejesi
    ------------------------------



  • 4.  RE: Using Variables in Formulas

    Posted 02-11-2020 11:22
    Uchenna,
    There is no formula function called DateTime
    Here is a list of of all the valid Quick Base Functions.  https://login.quickbase.com/db/6ewwzuuj?a=td

    I think that you meant to use the function called toTimeStamp.
    https://login.quickbase.com/db/6ewwzuuj?a=dr&rid=143&rl=bru


    var DateTime FebPRStart = ToTimeStamp(ToDate("02-01-2020", ToTiimeOfDay("12:00 AM");
    var DateTime FebPREnd = ToTimeStamp(ToDate"02-15-2020", ToTimeOfDay("11:59 PM");
    var Bool FebCalc = Now() >= $FebPRStart and Today()<=$FebPREnd;








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



  • 5.  RE: Using Variables in Formulas

    Posted 02-11-2020 13:03
    Thank you very much, Mark! I'm having an issue with the semicolon at the end of the first line. It says it is expecting an ). But, when I put that, it highlights the ToTimeofDay piece.

    ------------------------------
    Uchenna Ogbejesi
    ------------------------------



  • 6.  RE: Using Variables in Formulas
    Best Answer

    Posted 02-11-2020 13:18
    Edited by Austin K 02-11-2020 15:45
    Without testing it I believe this one should work. It was missing some parenthesis in a few spots. A misspelled word and also using Today at the end instead of Now. This might work, if not post back.

    This is just what Mark posted with those things adjusted.

    var DateTime FebPRStart = ToTimeStamp(ToDate("02-01-2020"), ToTimeOfDay("12:00 AM"));
    var DateTime FebPREnd = ToTimeStamp(ToDate("02-15-2020"), ToTimeOfDay("11:59 PM"));
    var Bool FebCalc = Now() >= $FebPRStart and Now() <= $FebPREnd;


  • 7.  RE: Using Variables in Formulas

    Posted 02-11-2020 14:14

    Austin,

    Thanks for being thorough.  I rushed my response and left him hanging.   :(



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



  • 8.  RE: Using Variables in Formulas

    Posted 02-11-2020 15:45
    Thank you very much, Austin! This worked!

    ------------------------------
    Uchenna Ogbejesi
    ------------------------------



  • 9.  RE: Using Variables in Formulas

    Posted 02-11-2020 16:07
    Tag team success. Thx Austin!

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