can convert date to another form?

hi, can convert x=('2005-04-20') into 2005,04,20
I wan to say that I got date from text using textscan i.e length of x=1
when I used datenum('2006-04-20','yyyy-mm-dd')
ans =
7.3279e+005
and when use
datenum('2006-04-19','yyyy-mm-dd')
ans =
7.3279e+005
it is not sensitive for small changes
but when used datenum(2006,04,19)
ans =
732786
datenum(2006,04,20)
ans =
datenum(2006,04,19)
ans =
732786
it is perfect
can got that?
thanks

 採用された回答

Daniel Shub
Daniel Shub 2011 年 11 月 8 日

0 投票

It is just a display formatting issue:
format long
datenum('2006-04-19','yyyy-mm-dd')
ans = 732786
datenum('2006-04-20','yyyy-mm-dd')
ans = 732787

その他の回答 (1 件)

Titus Edelhofer
Titus Edelhofer 2011 年 11 月 8 日

0 投票

Hi,
it looks as if the datenum of your string gives a fractional number (no integer). This happens, if the time is not 00:00:00. You can check using
datevec(datenum('2006-04-20','yyyy-mm-dd'))
What do you get? Do you get
2006 4 20 0 0 0
or something like e.g.
2006 4 20 12 23 35
Which version of MATLAB are you using, btw.?
Titus

カテゴリ

ヘルプ センター および File ExchangeTime Series Objects についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by