anyone know how to convert a date/time result in a...
# suiteanalytics
o
anyone know how to convert a date/time result in a saved search to all minutes or seconds using a formula?
g
You mean like getting the epoch time? Something like:
{datetimefiels}-to_date('1-1-1970 00:00:00','MM-DD-YYYY HH24:Mi:SS'))*24*3600
o
thank yoU!
@George McMullen i'm seeing that the parenthesis don't balance on that one
but basically, i'm trying to compare two date/time values
g
Oops. I must have missed it in my copy paste...
({datetimefiels}-to_date('1-1-1970 00:00:00','MM-DD-YYYY HH24:Mi:SS'))*24*3600
and of course datetimefiels should be called datetimefield, but I don't know what datetime field you're using. Replace it with your field name.
I think you should be able to compare two date time fields with something like:
CASE
WHEN {datetime1} > {datetime2}
THEN 1
ELSE 0
END
Then put that as a formula into your criteria. Of course, I may not know your exact use case.
b
you may have better luck simply subtracting the two columns from each other
{datetime1} - {datetime2}
should give a difference in days which you should be able to convert to your desired units
if the result is a weird looking interval, you should cast the timestamps to date
CAST ({datetime1} AS DATE) - CAST ({datetime2} AS DATE)
o
thanks @George McMullen and @battk yes with some testing i got it figured out.
g
👍