Help

Re: Compare NOW() or TODAY() with date field in a table

Solved
Jump to Solution
3779 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Pjero_Kusijanov
7 - App Architect
7 - App Architect

Hi :slightly_smiling_face:

I want to create formula that will return true if today is after date or s within two dates.
IF(AND(NOW()>{Check-in},NOW()<{Check-out}),“NOW”,"")

Above is the formula that does not work for me, it always returns false.

I would appreciate some help. Thanks

1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

When comparing date/time values, it is better to use the date/time comparison functions.
You can use the IS_BEFORE, IS_AFTER, and IS_SAME functions, or you can use the DATETIME_DIFF function.

IF(
  AND(
    DATETIME_DIFF(TODAY(), {Check-in}, 'days') >= 0,
    DATETIME_DIFF(TODAY(), {Check-out}, 'days') <= 0
  ),
  TRUE(),
  FALSE()
)

A couple of notes:

  • TODAY() and NOW() are not continuously updated. You may need to reload a base or view in order to update them.

  • TODAY() and NOW() return the GMT date and time, not local time. So if your {Check-in} and {Check-out} times are displayed as local dates, your results might be off by a day.

See Solution in Thread

4 Replies 4

Your formula works just fine for me. Be sure that you’re using “straight quotes” instead of “curly quotes”, so that your formula looks like this:

IF(AND(NOW()>{Check-in},NOW()<{Check-out}),"NOW","")

kuovonne
18 - Pluto
18 - Pluto

When comparing date/time values, it is better to use the date/time comparison functions.
You can use the IS_BEFORE, IS_AFTER, and IS_SAME functions, or you can use the DATETIME_DIFF function.

IF(
  AND(
    DATETIME_DIFF(TODAY(), {Check-in}, 'days') >= 0,
    DATETIME_DIFF(TODAY(), {Check-out}, 'days') <= 0
  ),
  TRUE(),
  FALSE()
)

A couple of notes:

  • TODAY() and NOW() are not continuously updated. You may need to reload a base or view in order to update them.

  • TODAY() and NOW() return the GMT date and time, not local time. So if your {Check-in} and {Check-out} times are displayed as local dates, your results might be off by a day.

Pjero_Kusijanov
7 - App Architect
7 - App Architect

Thank you both on your help. @ScottWorld Unfortunately the formula does not work for me, it may be because it’s Lookup field.

@kuovonne I manage to get this to work with IS_BEFORE and IS_AFTER.

@Pjero_Kusijanovic Oh okay, you didn’t mention that it was a Lookup field… key piece of information there! :winking_face: Glad that you got it working with the other Date functions that are available to you.