This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

datenum Might Not Return Correct Value

The results of the datenum function vary depending on the locale. To ensure the correct calculation of functions using date values associated with files and folders, replace datenum function calls with the use of the dir function datenum field.

For example, look at the modification date of your MATLAB® license_agreement.txt file:

f = dir('license_agreement.txt')

MATLAB displays information similar to:

f = 

       name: 'license_agreement.txt'
       date: '10-May-2015 17:48:22'
      bytes: 5124
      isdir: 0
    datenum: 7.3317e+005

If your code uses the date field of the dir command, similar to:

n = datenum(;

replace it with the datenum field:

n = f.datenum;

See Also

Was this topic helpful?