Skip to main content

Comparing NOW() to a certain time earlier today

  • October 17, 2022
  • 5 replies
  • 42 views

Forum|alt.badge.img+6
  • Known Participant

I need to be able to check and see if a certain time has passed in a formula field, and I don’t think I’m doing this right. My pseudocode is:

If now is past 10:30am today, then 1, otherwise 0

What would be the best way to go about this?

5 replies

Forum|alt.badge.img+16
  • Inspiring
  • October 17, 2022
IS_BEFORE(NOW(),Date)

Forum|alt.badge.img+6
  • Author
  • Known Participant
  • October 17, 2022

Thanks. How do I build the date & time desired?

How do I represent 10:30am on today?


Forum|alt.badge.img+6
  • Author
  • Known Participant
  • October 19, 2022

Bump… any thoughts?


kuovonne
Forum|alt.badge.img+29
  • Brainy
  • October 19, 2022

This is trickier than you might think. You need to convert the time to your local time zone. You also need to get the time without the date.

You should also know that NOW() isn’t very accurate. It only updates periodically. In my experience it updates at best every few minutes, and at worst every few hours.

I’m also guessing that you want to do more with the formula result than just see a 1 or 0. Because someone could just look at a clock to figure that out.

IF(
    SUM(
        HOUR(
            SET_TIMEZONE(
                NOW(),
                'America/New_York'
            )
        ) * 100,
        MINUTE({Session Start Time})
    ) < 1030,
    1,
    0
)

If you are in a timezone where your offset from GMT is not in full hours, you will also need to set the timezone for the minutes.


Forum|alt.badge.img+6
  • Author
  • Known Participant
  • October 21, 2022

Huh, well if Now() isn’t accurate - is there a better suggestion?