Thursday 15 May 2014

How determine date format in MATLAB -


I want to know in MATLAB which is the date pattern used by Excel. The reason for this is that I read an excel file from MATLAB, but the user is displayed as dd-mm-yyyy or mm-dd-yyyy to find the date based on the machine.

Clarification: Sorry for my bad explanation. This is my scenario. I have an excel file with dates (and other columns, not relevant to this problem). I have two computers that need to run my matlab application. The first time I use in xlsread (MATLAB), due to the regional configuration of my computer, the date appears in the format dd-mm-yyyy , I read the same file in the same MatLab version, but the dates read are in mm-DD-Yay format (again, due to the regional configuration of Computer 2, which is compute Differs from 1).

Now, when I try to use Datanam, in today's conversion, I can not use the parameter correctly in the format, because if I format the MM-DD-YAY Alright, I will work properly in computer 1, not 2 in computer, and vice versa.

So, I think I need to identify in MATLAB which is the date pattern used by Excel in the computer to find the correct input parameter for the parameter in that format. .

It is impossible to do this until you know your data really well. For example, if you have an annual reading for 01/07/20XX, it is impossible to know whether it is January 7 or July 1.

However, you can try the following:

  MyString = '01 -23-2012 '; FirstTwo = str2num (MyString (1: 2)); If (first two & gt; 12) performance ('DD / MM'); Other performance ('MM / DD'); End   

If the first two digits of the date are more than 12, then you can probably conclude that you have DD / MM / YYYY. I will loop more than all your dates. can do.

No comments:

Post a Comment