In Alteryx, in order to bring back your previous month's date 4 date functions are required.
DateTimeTrim([DateTime_Out],'month') =
DateTimeTrim( DateTimeAdd(DateTimeToday(),-1,'month'),'month')
Here is what each section means-
- DateTimeToday(): This function returns the current date and time.
- DateTimeAdd(DateTimeToday(), -1, 'month'): This part of the calculation takes the current date and time (DateTimeToday()) and subtracts one month (-1, 'month'). So, it calculates the date and time that occurred one month ago from the current date and time.
- DateTimeTrim(): This function is used to trim a date/time value to a specified level of precision. In this case, the precision level specified is 'month'. So, it trims the given date/time value to the first day of the month.
- DateTimeTrim([DateTime_Out], 'month'): This is the main part of the calculation. It trims the date/time value stored in the field named 'DateTime_Out' to the first day of the month.
Putting it all together, this calculation essentially takes the date/time stored in the field 'DateTime_Out', goes back one month from that date, and then trims it to the first day of that month. So, it effectively gives you the first day of the month that occurred one month before the date stored in 'DateTime_Out'.
This calculation can be used in a filter tool, and the correct output will be returned in the True Anchor: