%% Determine the Quarter for a Given Date When the Date is Not Recognized by datenum
% When using quarter, the optional input argument for dateformat is a character vector which lets you specify the format of your date character vector in case it isn't normally recognized by the datenum function.

quarter('07-04-2013',1)

% This gives the quarter 3 because by default datenum interprets the date as July 7th, 2013.
%
% If you really meant April 7th, 2013, you can use dateformat to specify the intended format.

quarter('07-04-2013',1,'dd-mm-yyyy')

% Copyright 2012 The MathWorks, Inc.