I have a date column 1/1/2017 that I need to convert to quarter and year 1Q 2017. What is the best way to do that?
Thanks in advance.
Probably not the best way to go about this, but I don't think there are any 'quarter' capabilities with alteryx's default date time tools (though James Dunkerlys add on may have this level of detail in).The following formula should suffice (presuming your date is in the format MM/DD/YYYY)
IF
tonumber(left([datefield],findstring([datefield],"/"))) < 4 then "1Q "
elseif
tonumber(left([datefield],findstring([datefield],"/"))) < 7 then "2Q "
tonumber(left([datefield],findstring([datefield],"/"))) < 10 then "3Q "
else "4Q "
endif
+ Right([datefield],4)
and if your date format is dd/mm/yyyy then the following should do...
tonumber(substring([datefield],findstring([datefield],"/")+1,findstring(right([datefield],length([datefield])-(findstring([datefield],"/")+1)),"/"))) < 4 then "1Q "
tonumber(substring([datefield],findstring([datefield],"/")+1,findstring(right([datefield],length([datefield])-(findstring([datefield],"/")+1)),"/"))) < 7 then "2Q "
tonumber(substring([datefield],findstring([datefield],"/")+1,findstring(right([datefield],length([datefield])-(findstring([datefield],"/")+1)),"/"))) < 10 then "3Q "
+ Right([datefield],4)See the attached workflow to see how I have implemented these.Regards,Ben
Thanks Ben,
Worked like a charm. Big help.
What would this formula look like if my date is in this format yyyy-mm-dd?
Thanks so much for this string/formula - worked perfectly!