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

10 views (last 30 days)
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?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 26 Nov 2019
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:

More Answers (0)

Categories

Find more on Timetables in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!