Change time in a timeseries object

4 次查看(过去 30 天)
Hello everybody!
I have a timeseries object in which the time is expressed as follow:
val =
'16-Jan-2014 12:00:00'
'15-Feb-2014 00:00:00'
'16-Mar-2014 12:00:00'
I wuold like to have the time in the 'dd - mm - YYYY' information, i.e. like this:
val =
'16-Jan-2014'
'15-Feb-2014'
'16-Mar-2014'
Is there a way to do that?
Many thanks!

采纳的回答

Walter Roberson
Walter Roberson 2021-6-30
编辑:Walter Roberson 2021-6-30
Suppose TS is your timeseries. Then
TS.TimeInfo.Format = 'dd-mmm-yyyy';
after which
getabstime(TS)
would use that format.
The format specification uses datestr(), not datetime() forms, and there are a limited number of supported formats. It must be one of the forms returned by tsgetDateFormat(). Exact matches are used -- case sensitive, no added spaces permitted, and you cannot use different delimiters.
{'dd-mmm-yyyy HH:MM:SS' }
{'dd-mmm-yyyy HH:MM:SS.FFF'}
{'dd-mmm-yyyy' }
{'mm/dd/yy' }
{'HH:MM:SS' }
{'HH:MM:SS.FFF' }
{'HH:MM:SS PM' }
{'HH:MM:SS.FFF PM' }
{'HH:MM' }
{'HH:MM PM' }
{'mmm.dd,yyyy HH:MM:SS' }
{'mmm.dd,yyyy HH:MM:SS.FFF'}
{'mmm.dd,yyyy' }
{'mm/dd/yyyy' }

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Time Series 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by