Code covered by the BSD License  

Highlights from
xlsdate.m

from xlsdate.m by Mark A. Mikofski
converts a MS Excel date to year, month and day

xlsdate(date)
function [year,month,day] = xlsdate(date)
% does the exact same thing as [y,m,d] = datevec(date+697560)

year = 1900; % xls starts at 1900
x = date-366; % 1900 was a leap year, move to 1901
while x>1
    year = year+1;
    if mod(year,4)==0 % check if leap year
        x = x-366;
    else
        x = x-365;
    end
end

% undo last subtraction
if mod(year,4)==0
    x = x+366;
else
    x = x+365;
end

if x<31 % check if January
    month = 1;
    day = x;
else    
    month = 1; % start at January
    x = x-31; % move to nect month
    while x>=1
        month = month+1;
        if sum(month==[1 3 5 7 8 10 12])==1
            x = x-31;
        elseif month==2 & mod(year,4)==0
            x = x-29;
        elseif month==2 & mod(year,4)~=0
            x = x-28;
        else
            x = x-30;
        end
    end
    if sum(month==[1 3 5 7 8 10 12])==1
        x = x+31;
    elseif month==2 & mod(year,4)==0
        x = x+29;
    elseif month==2 & mod(year,4)~=0
        x = x+28;
    else
        x = x+30;
    end
    day = x;
end

Contact us at files@mathworks.com