bug of addtodate when combining with now?

addtodate function returns very odd results when combined with now.
>>datestr(now,'yyyymmdd')
ans =
20140814
>>datestr(addtodate(now,-1,'day'),'yyyymmdd')
ans =
19700101
>>datestr(addtodate(now,1,'day'),'yyyymmdd')
ans =
19700101
Is that a known bug? Or have I missed something obvious?

3 Comments

Yucheng,
I am not able to reproduce this:
>> datestr(addtodate(now,1,'day'),'yyyy-mm-dd')
ans =
2014-08-15
>> datestr(addtodate(now,-1,'day'),'yyyy-mm-dd')
ans =
2014-08-13
What version of MATLAB are you using? How about your OS? You can check this by typing:
>> ver
Also
which now
which addtodate
just to be sure haven't aliased something somehow.
If after all the sanity checks and 'clear all' still does it, it's bug report time, fur shure...
Also, indeed can't reproduce it here, either R2012b which is getting somewhat date, granted...
Thanks for looking into the problem. It is a bit frustrating that I cannot reproduce the same problem today when I tried again (even though I have not even restarted my matlab):(

Answers (0)

This question is closed.

Asked:

on 14 Aug 2014

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!