Discussion:
datestr problem
LucaLuca
2018-11-20 23:09:45 UTC
Permalink
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
mmuetzel
2018-11-21 17:53:30 UTC
Permalink
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
mmuetzel
2018-11-21 18:06:23 UTC
Permalink
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
Loading...