How can I save custom date formats to the Input Tool dialog in MATLAB R2022b?

8 views (last 30 days)
Is there a way to save (or set) custom datetime formats in the Import Tool dialog so that they can be reused after restarting MATLAB R2022b and/or Import Tool? My use case is that I often need to enter the following custom format:
yyyy.DDD.HH:mm:ss
It would be helpful to have that appear as a custom option at the top of the list after it has been used. It does that now if I don't close the Import Dialog, but it doesn't reappear if I close the Import Dialog or restart MATLAB. I would prefer to have a persistent list of the most recently used formats instead of (or at the top of) the existing list of sample formats.
The image below shows the custom datetime format that I have created, which I would like to remain persistent:

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 9 Mar 2023
A way to use custom formats is to import your data programmatically. This would involve importing a data file using code that performs custom date formatting without having to manually specify it. For example, for the following “datafile.txt” file:
2000.003.06:09:12
2001.004.07:10:13
2002.005.08:11:14
You can use the “readtable” MATLAB function and its “Format” property to specify a custom date format as follows:
T = readtable("datafile.txt", "Delimiter", " ", "Format", "%{yyyy.DDD.HH:mm:ss}D %d");
For more information regarding the “readtable” function, please refer to the documentation linked below:
Saving the custom format in the graphical interface is something our development teams are considering for future MATLAB releases.

More Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!