Check if more than 3 hours
-
16-10-2019 - |
Question
I need a calculated column to display "Yes" if the current time is more than 3 hours after the value of another column. This is what I've come up with:
=TEXT(Today-[AddTime],"h")>3
But SP tells me this is invalid. Are there other ways of doing this?
Larsi
Solution
As you google around for this you are going to come across pages telling you you can do this with calculated columns using the [Today] trick.
You can't, it doesn't work and isn't updated dynamically - and even if it were [Today] doesn't include a time component so X hrs is out.
A couple of options for you
- Use a CEWP and JavaScript to modify the display to show your Yes/No column.
- Create a custom dataview usign SharePoint Designer/XSLT.
- Use Workflow to run a job X hours after your record has been inserted to change the Yes/No column.
OTHER TIPS
You may want to look at this, it's a good primer for calculated columns. Also, Today and Me are not allowed in calculated columns.
Excuse my self-promotion, but:
We've developed a custom column that can do just that, which is currently in Public Beta: http://www.pentalogic.net/sharepoint-products/highlighter/beta-testers-guide
To set it up to do this, you'd choose:
- Highlighting
- Display: Cell highlighting
- Rules: Click "Add custom", then add the following two rules:
This can likely be implemented not in a calculated column but in a computed column. The difference being that a calculated column is only calculated during edits, and a computed column for each render.
Wouter