Currently, the native DateTimeTrim() function within Alteryx only offers very limited time horizons, namely:
- firstofmonth
- lastofmonth
- year
- month
- day
- hour
- minute
This custom macro expands upon the current tool's capabilities and provides support for several extra date parts. As well as most of the original functionality, the macro is also capable of returning the following once a target date field has been selected:
- Next Day - Returns the date corresponding to the next day
- Start of Week - Returns the date corresponding to the beginning of the week (Monday to Sunday)
- End of Week - Returns the date corresponding to the end of the week (Monday to Sunday)
- Start of Quarter - Returns the date corresponding to the first day of the quarter
- End of Quarter - Returns the date corresponding to the last day of the quarter
- End of Year - Returns the date corresponding to the last day of the year
- Financial Year - Returns the current financial year in a YYYY/YY format
- Quarter - Returns the quarter i.e. 1/2/3/4
- UK Rail/Travel Industry Period - Often within said industry, the financial year is broken up into 13 x 4 week periods, instead of months. This returns the current period
- Start of UKRTI Period - Returns the date corresponding to the first day of the UK Rail/Travel Industry Period
- End of UKRTI Period - Returns the date corresponding to the last day of the UK Rail/Travel Industry Period
This macro was designed to automate a few calculations that I had to repeat on multiple occasions, as well as some semi-frequent requests I'd seen throughout the community discussion forums and a couple of replies to requests for alternative timeframes. If you'd like to request another date part, or provide any other suggestions/feedback/criticism then all are welcome!