Main Content


(Not recommended) Convert CDF epoch object to MATLAB serial date number

todatenum is not recommended. Use cdfread instead. (since R2023b) For more information on updating your code, see Version History.


n = todatenum(ep_obj)


n = todatenum(ep_obj) converts the cdfepoch object ep_obj to a MATLAB® serial date number. A CDF epoch is the number of milliseconds since 01-Jan-0000, while a MATLAB datenum value is the number of days since 00-Jan-0000.


Construct a cdfepoch object from text that represents a date. Then, convert the object back to its original form.

dstr = datestr(today)
dstr =

obj = cdfepoch(dstr)
obj =
     cdfepoch object:
     08-Oct-2003 00:00:00

dstr2 = datestr(todatenum(obj))
dstr2 =

Version History

Introduced before R2006a

collapse all

R2023b: Not recommended

There are no plans to remove todatenum. However, todatenum is not recommended. Use the cdfread function instead.

The todatenum function converts cdfepoch objects to serial date numbers, which are not recommended. Update your code to convert this type of data to datetime or double values instead. For example, use cdfread(filename,"DatetimeType","datetime").