Datetime column used in formula

Hello i am trying to create a select expression to filter out rows that have a datetime in the past 12hours, so less than now() but more than now()-12hours, this is what i have done as a starter but it doesnโ€™t work SELECT([Related Ref Logs][ID], anD([Datetime]>now(), [Datetime] < (now()-12:00:000))

0 5 393
5 REPLIES 5

The problem is you are mixing DateTime and time.

So [Datetime]>now() works fine as both are datetime but [Datetime] < now() - 12:00:00) is not as now() is datetime and 12:00:00 time).

Rather use TIME(now())-12:00:00) or TIMENOW()-12:00:00)

Also, your expression is incorrect it should be

AND( [Datetime]<=now(), [Datetime] >= (TIMENOW()-12:00:000) )

Steve
Platinum 4
Platinum 4

This expression:

anD([Datetime]>now(), [Datetime] < (now()-12:00:000)

is testing that:

  1. The Datetime column value is later than now (i.e., in the future).

    AND

  2. The Datetime column value is earlier than 12 hours ago (i.e., in the past).

A single DateTime cannot be both in the future and in the past at the same time.

Try replacing AND() with OR().

@Steve
Might this work better do you think?

AND(
	[Datetime] >= now() - 12:00:00,
	[Datetime] <= now()
)

Thanks for all your help, i am still having trouble - i have simplified it down to this to start with but it still does not work SELECT([Related Ref Logs][ID], [Datetime] < now())

Actually ignore that, It was the way the columns were set up, for some reason the datetime column was showing as long text,

Top Labels in this Space