datestr problem

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

datestr problem

LucaLuca
hi
look that :

c1
  ans =
  {
    [1,1] = 01/02/14
  }


c2
 ans =
  {
    [1,1] = 15/02/14
  }

ok it seem ok..

now i try to use datestr :

datestr(c1,20)

ans = 02/01/14  ===> this is okey

datestr(c2,20)
ans = 14/02/15  ===>> THIS IS NOT OKEY..THERE IS A PROBLEM




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: datestr problem

mmuetzel
If you call datestr with a string as input argument, it is passed to datevec
which in turn uses some heuristics to guess the date format. This could
probably be better documented in the help string for datestr.

If you know which date format you are using in the input, it is better (and
faster) to pass that:
datestr(datenum(c1{1}, 'dd/mm/yy'), 20)
or
datestr(datenum(c1{1}, 'yy/mm/dd'), 20)
or whatever your input date format is...

Markus



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: datestr problem

mmuetzel
I updated the help string of datestr to include the following:
## @var{date} is a serial date number (see @code{datenum}), a date vector
(see
## @code{datevec}), or a a string or cell array of strings. In the latter
case,
## it is passed to @code{datevec} to guess the input date format.

Markus




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html