View Single Post
Old 03-19-2022, 05:34 PM   #356
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,476
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Question:

I have two timedate columns with a difference of less than an hour.* If I put the raw input into a days_between, depending on what order I either get 0.0 or -0.0.

Is the negative intended or a bug? There's something called a signed zero but I don't quite understand what it means.

I tried multiplying to see what would happen but still got -0.0.

* 2022-03-19 02:03:12+00:00 and 2022-03-19 03:00:00+00:00 exactly.
It means that there are digits you aren't seeing. It is formatted with 1 decimal place, the 10ths column. The full result will have a value in the 100ths or maybe even the 1000ths column. Thus the answer is less than zero.

If you don't like it, use round(), floor(), or ceiling(). Or convert the dates to timestamps, do the arithmetic, divide the result by 86,400 to get the fractional days, then format it with whatever precision you want.
chaley is offline   Reply With Quote