How can I use retime to convert to monthly time frequency, and display the data for end of month dates?

8 次查看(过去 30 天)
I would like to alter my timetable to display end-of-month dates, rather than start-of-month dates. How can I use the retime function to achieve this?

采纳的回答

MathWorks Support Team
The "retime" function (used with timetables) operates differently than the "tomonthly" function used with TimeSeries data, as it displays the new monthly frequency table with start-of-month datetimes rather than end-of-month datetimes.
The trick is to use the following version of retime:
TT2 = retime(TT1,newTimes,method)
and pass in the end of month date times as the variable "newTimes".
Attached is a script ("test_script.m") which demos how to create a time-series time table and how to convert them to monthly time-series and timetable respectively and the differences between the two.
The "retime" function is extensive and can be used for a variety of functions that were used to manipulate TimeSeries objects. The documentation for "retime" can be found here:
The general workflow for converting code that uses time series over to timetables can be found here:
You might have to use additional functions that operate on "datetime" arrays to get to the final result (Eg - "eomdate" in attached code).
A full list of functions that operate on "datetime" arrays can be found here:

更多回答(0 个)

类别

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

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by