|
From: | Nicholas Jankowski |
Subject: | Re: problem parsing time out of datetime object |
Date: | Fri, 20 Oct 2017 15:44:47 -0400 |
AG wrote
> I am trying to parse a datetime string into two pieces, date and time, and
> I'm trying to figure out why this code does not work. According to the
> docs
> it seems that a call to rem on a datetime will give you the time but it
> doesn't seem to do that.
>
> dt_num = datenum('2013/05/29 00:00:00','YYYY/DD/MM HH:MM:SS')
>
> d_num = floor(dt_num)
> t_num = rem(dt_num,1)
>
> datestr(d_num) ## ans = 05-Jan-2013 (RIGHT!)
> datestr(t_num) ## ans = 31-Dec--001 (WRONG)
Seems perfectly OK to me. What else would you expect for a date in the year
0, month 0, day 0? :-)
But perhaps you meant:
>> datestr (t_num, 13)
ans = 00:00:00
(try "help datestr" to see datestr's output options)
Philip
[Prev in Thread] | Current Thread | [Next in Thread] |