#MATLAB / Octave, 42 bytes
MATLAB / Octave, 42 bytes
@(x)upper(datestr(datenum(x,'yyyymm'),12))
Creates an anonymous function named ans
that is called with a string representing the date: ans('201604')
.
This solution uses datenum
to convert the input date to a serial date number, and then datestr
with the predefined output spec of mmmyy
(12
) to yield the string representation in the required format. Finally, we use upper
to change it to MMMYY
since the uppercase month is not an output option.