We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

DateTimeAdd function giving inconsistent results

sagar_ghimire
5 - Atom

Why are we getting different results between   DateTimeAdd([Field1], -(7/5)*45 , "Days")  and  DateTimeAdd([Field1], -(45*7/5) , "Days")

When we have Field1 = "2025-03-16" for instance, we get 2025-01-13 and 2025-01-12 

What are we overlooking? Both -(45*7/5) and -(7/5)*45 should result in -63. 

 

Thanks in advance.

11 REPLIES 11
Pilsner
13 - Pulsar

@KGT , that's a great explanation about the full days, thanks for explaining that. 

@sagar_ghimire , regarding documentation, if you want to know about the data types themselves, then you can see Alteryx's documentation here
https://help.alteryx.com/current/en/designer/file-types-support/data-types.html##

However, if you want to understand how doubles etc, work under the hood, in terms of being encoded, then this isn't specific to Alteryx. I'm not aware of an Alteryx article explaining this, but I have found one elsewhere:
https://medium.com/@JeffreyLean/the-secret-life-of-floating-point-types-in-programming-languages-e25...
If you scroll down approximately halfway in this article, they explain the way computers store decimals in more detail by using the example calculation 0.1 + 0.2 = 0.3000...04.

dreldrel
8 - Asteroid

The discrepancy happens might because of the order of operations combined with integer division and implicit casting inside Alteryx. 7/5 is not exactly 1.4 in this context, it is treated differently, which leads to truncation

Labels
Top Solution Authors