I’m trying to show the difference the current time...
# general
j
I’m trying to show the difference the current time and a datetime field in a Saved Search formula. Currently, my field is of type
Formula (Text)
and my formula is
sysdate - {custrecord_my_datetime_field} || ''
, which gives me something that looks like
+000000000 01:34:12.000000
. Ideally, I want something formatted as follows
0 day(s), 0 hour(s), 1 minute(s), 34 second(s)
or similar. I’ve tried using TRUNC to extract even just the days (e.g.
TRUNC(sysdate - {custrecord_my_datetime_field}) || ''
but that just results in an Unexpected Error page when I try to run the search. Any suggestions on how to achieve this?
j
As I said, TRUNC doesn’t work. The above only works with Dates, not Datetimes.
n
@jen you need your time difference as a number. Check SA18390 for some example calcs https://netsuite.custhelp.com/app/answers/detail/a_id/18390
j
No joy, that gives me an invalid expression
message has been deleted
message has been deleted
n
what's the field type of _last__alive_time?
j
Date/Time
n
can you explain that formula {today} - {_last__alive_time} what is your intention with the *1440
I am thinking {now} - {last_timestamp} so they will both be same format which can be subtracted to give you the interval
w
Copy code
extract(day from (systimestamp-{custrecord_datetime})) || ' day(s), ' || extract(hour from (systimestamp-{custrecord_datetime})) || ' hour(s), ' || extract(minute from (systimestamp-{custrecord_datetime})) || ' minute(s), ' || round(extract(second from (systimestamp-{custrecord_datetime}))) || ' second(s)'
message has been deleted
It looks like the field Date/Time is stored/displayed with my timezone gmt+1 and the systimestamp uses the server time gmt-8. The comparison however is performed with both in the same timezone, which is good.
j
@Netsuite Tragic the
*1440
thing was directly copied from the link you posted
Brilliant, thank you @Watz! Looks like my issue was using
sysdate
instead of
systimestamp
.