|
"Steven Lord" <slord@mathworks.com> wrote in message <h11doj$fg8$1@fred.mathworks.com>...
>
> "Andrey Kazak" <AK@nospam.ru> wrote in message
> news:h10ll6$9up$1@fred.mathworks.com...
> > Greetings!
> >
> > The extract from MATLAB help for "datenum" function:
> > N = datenum(S, F, P) converts one or more date strings S to date numbers N
> > using format F and pivot year P. The pivot year is used in interpreting
> > date strings that have the year specified as two characters. It is the
> > starting year of the 100-year range in which a two-character date string
> > year resides. The default pivot year is the current year minus 50 years.
>
> That's correct.
>
> > So, as I understand from the text, if current year is 2009 than the
> > default will be 2009 - 50 = 1959. However the command:
> >
> > datestr(datenum('12.01.13', 'dd.mm.yy'),'dd.mm.yyyy')
> >
> > gives the following result:
> >
> > 12.01.2013
> >
> > Year is 2013, but not 1959+13 = 1972.
> >
> > Could you help me please to figure out what this is: my misunderstanding,
> > wrong help or a bug?
>
> Because the default pivot year is 1959, that means a 2-digit year
> corresponds to the unique year in 1959+(0:99) that has those last two
> digits. (0:99) is the "100-year range" referred to in the help, and 1959 is
> the starting year of that range. So the year whose last digits are 13
> correspond to 2013, since 1959 <= 2013 and 2013 <= 2058 (=1959+99).
>
> --
> Steve Lord
> slord@mathworks.com
>
Thank you, Steven!
Now its clear for me. However, are you sure of range (0:99)?
For example, this command:
datestr(datenum('12-jun-13', 'dd-mmm-yy',1913),'dd.mm.yyyy')
gives
12.06.2013
Year is still 2013, but not 1913 + 0 = 1913.
Perhaps the correct search range for the pivot year is (1:100)?
|