Formula on saved search: Trying to do something li...
# general
g
Formula on saved search: Trying to do something like now minus custom field - if the time is greater than 1 day/24hours then X else Y 2 fields are: {now} {custbody_time} The custbody is a date/time field and looks something like 23/11/2023 192826 so ideally if {now} = 24/11/2023 212826 THEN based on formula, it should be X Don't think the TO_DATE is the right one to use... currently I have: CASE WHEN ({now}- TO_DATE ({custbody_time})) > 1 THEN X ELSE Y END
s
You could do the time part of it could work as this this:
Copy code
CASE WHEN TO_CHAR({custbody_time}, 'HH24:MI:SS') <= TO_CHAR ({now}, 'HH24:MI:SS') THEN 1 ELSE 0 END
And then you could separately do custbody_time on or before yesterday for the date part. (I've only split out time separately for hourly comparisons and had the dates hard-coded, so never tried to do them both in one.)
g
thanks @Stephanie Hughes what if I wanted hours difference? i.e. if time between custbody_time is greater than or equal to 1 hour then 1 else 0? Tried --> CASE WHEN TO_CHAR({custbody_commerce_placed_timestamp}, 'DD/MM/YYYY HH24MISS') - TO_CHAR ({now}, 'DD/MM/YYYY HH24MISS') <= 0.0416 THEN 1 ELSE 0 END - doesn't work
s
That I don't know; I just know the formula and info above can get you on or before the same time yesterday (i.e. 24+ hours ago), which is all I've needed to do (not calculate hours difference).