Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Changing the format of dates in MATLAB

Subject: Changing the format of dates in MATLAB

From: Emilio Cazares

Date: 11 Jul, 2014 18:21:15

Message: 1 of 3

Hello,

I am not very proficient in string handling so Ill do my best to explain.

I have list of thousands of dates in this format in a .txt file

09/15/1992
08/19/1998
.
.
.
mm/dd/yyyy

and my goal is to convert them to this format

1992 09 15
1998 08 19
.
.
.
yyyy mm dd

but the problem is that I can't seem to copy and paste the initial date data and get it into a usable form. I am unable the turn it into a string or anything that MATLAB doesn't regard as an error.

I am fine with writing a new function to perform this task or use MATLAB ones. Not really sure what to do.

Thanks


-Emilio

Subject: Changing the format of dates in MATLAB

From: dpb

Date: 11 Jul, 2014 18:52:18

Message: 2 of 3

On 07/11/2014 1:21 PM, Emilio Cazares wrote:
...

> I have list of thousands of dates in this format in a .txt file
>
...
> .
> mm/dd/yyyy
>
> and my goal is to convert them to this format
...
> yyyy mm dd
...

 >> dt=importdata('test.dat') % sample input
dt =
     '01/01/2000'
     '10/23/2014'
 >> ds=datestr(cellfun(@datenum,dt),'yyyy mm dd')
ans =
2000 01 01
2014 10 23
 >>

--

Subject: Changing the format of dates in MATLAB

From: Emilio Cazares

Date: 11 Jul, 2014 19:24:17

Message: 3 of 3

Thanks. Fixed my problem.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us