Jun 30, 2020 09:59 AM
Hello all!
I want to have countdown (showing how many days left) based on the stage (a single select field) of a record. Each stage should take a certain amount of time to complete, so the goal is to see how many days left I have to complete a stage. Then once I change it to the next stage, that countdown is reset to the parameters of the next stage.
I have parameters are mostly set by formula-based date fields that live in the table. So it would look something like this:
If {Stage}=Stage 1, calculate difference between {date 1} & 14 days from {date 1}
If {Stage}=Stage 2, calculate difference between {date 2} & 14 days from {date 2}
If {Stage}=Stage 3, calculate difference between {date 3} & 28 days from {date 3}
If {Stage}=Stage Complete, “Complete”
I tried doing a DATETIME_DIFF inside of the If function, but have been struggling with errors. Seems pretty straight-forward, but I can’t figure it out…
Any help would be great! Thanks in advance.
Solved! Go to Solution.
Jul 02, 2020 10:18 AM
Hi @David_Gutierrez,
If I’m understanding your question correctly, you’d like to:
If that’s correct, here’s a formula you can use:
SWITCH(
{Stage},
"Stage 1",
DATETIME_DIFF(DATEADD({Date},14,'days'),NOW(),'days'),
"Stage 2",
DATETIME_DIFF(DATEADD({Date},14,'days'),NOW(),'days'),
"Stage 3",
DATETIME_DIFF(DATEADD({Date},28,'days'),NOW(),'days'),
"Complete", "Complete"
)
This uses the SWITCH()
function rather than IF statements for a slightly more straightforward approach. You’ll see in the GIF below how the countdown adjusts based on the entered date and the current time (the NOW()
function in the formula).
Let me know if that helps!
Jul 02, 2020 10:18 AM
Hi @David_Gutierrez,
If I’m understanding your question correctly, you’d like to:
If that’s correct, here’s a formula you can use:
SWITCH(
{Stage},
"Stage 1",
DATETIME_DIFF(DATEADD({Date},14,'days'),NOW(),'days'),
"Stage 2",
DATETIME_DIFF(DATEADD({Date},14,'days'),NOW(),'days'),
"Stage 3",
DATETIME_DIFF(DATEADD({Date},28,'days'),NOW(),'days'),
"Complete", "Complete"
)
This uses the SWITCH()
function rather than IF statements for a slightly more straightforward approach. You’ll see in the GIF below how the countdown adjusts based on the entered date and the current time (the NOW()
function in the formula).
Let me know if that helps!
Jul 02, 2020 11:10 AM
Well that definitely worked. Thanks a ton!!
Jul 02, 2020 03:39 PM
Happy to help out David!