- use a calendarduration or duration object to store the lowest known unit, e.g. duration 00:01:00.000
- similarly with a date vector, e.g. [0,0,0,0,1,0] (downside: not scalar, but perhaps slightly easier to work with)
- similarly with a logical vector, e.g. [false,false,false,false,true,false] (downside: not scalar)
- store one single integer index/count of the known units, e.g. 5 would indicate data is known to the nearest minute.
How to store partially known datetimes
1 view (last 30 days)
Russell Shomberg on 7 Oct 2020
What is the best way in MATLAB to deal with partially known date times?
I have a list of dates and times as part of a database. For most, I know the full date and time, but for many I only know down to the day, or month, or even just year. Currently, I have them stored in a table seperated by year, month, day, and time, but I would much prefer a single field if possible.
Is there a way to use the datetime or other datatype in MATLAB to convey that information about the date and time could be missing?
Stephen23 on 8 Oct 2020
Edited: Stephen23 on 19 Oct 2020
I don't believe that information can be encoded inside one datetime object, so you will have to use another object or variable to hold that information (which could be another datetime).
Here are a few idea (all examples are known down to the nearest minute):
I would start with the fourth option (on the basis that this is by far the simplest) and see if that could work for your algorithm.