I've just noticed something when using DateTimeFirstOfMonth() that I hadn't seen before.
If I have a filter on a date field with an expression:
[Date] < DateTimeFirstOfMonth()
and my Date is 2017-02-01, first of month is 2017-02-01, I would expect this record to be outputted as false since it is not before that date. However, it is outputted as true.
If I do the same but change my data type to datetime, the record is now outputted as false.
Obviously the datatype is making a difference but I'd expect consistent output between the two.
Solved! Go to Solution.
Here are some to consider:
Date data type vs Date data type:
"2017-04-01" < "2017-04-01"
results in False, because they are the same value
DateTime data type vs DateTime data type:
"2017-04-01 00:00:00" < "2017-04-01 00:00:00"
results in False, because they are the same value
Date data type vs DateTime data type:
"2017-04-01" < "2017-04-01 00:00:00"
results in True, because they are not technically the same value. The Date has a Null value for Time, while the DateTime has a value of zero for the Time. If you sort Null vs zero, the Null will be sort as first.
Apparently to Alteryx, a Date with Null Time is less than the same DateTime with a zero for Time.
The function DateTimeFirstOfMonth() will return a DateTime date type value, maybe what we need is a function for DateFirstOfMonth that returns a Date data type value.
Currently all built-in DateTime functions return a DateTime data type, and I do not know of a built-in function to convert a DateTime to a Date data type.
Although thanks to @jdunkerley79 we can do what you need with his Alteryx Formula Add Ins at https://jdunkerley.co.uk/2016/05/15/alteryx-formula-add-ins-v1-1/
Then you can write an expression like:
[Date]<TODATE(DateTimeFirstOfMonth())
and it will behave exactly how you expect it to because it is comparing a Date data type vs a Date data type.
User | Count |
---|---|
19 | |
15 | |
15 | |
9 | |
8 |