Alteryx Designer Desktop Discussions

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

Datetime and Date comparison

PaA
5 - Atom

Alteryx fails to correctly compare for equality datetime and date despite date->datetime conversion exists and after the conversion the comparison is done correctly. Am I missing something?
It looks like the comparison is done alphabetically (after -> to string conversion as a common type ???). I would prefer either 'invalid operator exception' or conversion to datetime as common type.


(I am guessing the alphabeticall comparison because [datetime]>[date]==true which is same behaviour as for string)

update: to make it more obvious - the question is why Alteryx even allows such comparison when it does not make any sense? (as I said "invalid operator" would make more sense than this result)

PaA_0-1628771215744.pngPaA_1-1628771225714.png

 

4 REPLIES 4
atcodedog05
22 - Nova
22 - Nova

Hi @PaA 

 

Try

 

 

[Date]=ToDate([Datetime]) 

 

 

To convert to date

 

atcodedog05_0-1628771661081.png

 

Hope this helps : )

PaA
5 - Atom

@atcodedog05
Now (after making mistake) I know I have to do type conversion to make the equality work (either to date -> datetime or datetime -> date).
Question is, why alteryx "allows" me to do direct comparison when the result does not make any sense?
That's imho faulty behavior. For example I cannot compare "1" and 1 (despite common type string exists) so why I can compare date and datetime when the comparison is done alphabetically??

atcodedog05
22 - Nova
22 - Nova

Hi @PaA 

 

You look at date and datetime as Int and double

 

Int has no decimal similar way date does not have time.

Double has decimal similar way datetime has time.

 

 

Int and double are numeric datatypes. Values are similar only representation changes.

Date and Datetime are date datatypes. Values are similar only representation changes.

 

Hope this helps : )

PaA
5 - Atom

Hi @atcodedog05

And in what language does 1 (int) != 1.0 (double) ? Either it is cast exception or there is autocast and result is true.
That's what I am trying to say either the types should be uncomparable or the result should be true.

Labels