Got Questions? Get Answers.
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:
numbers to dates

Subject: numbers to dates

From: enviro

Date: 18 Apr, 2010 08:31:11

Message: 1 of 5

Hi there,
How to convert numbers to dates. In the below 10321 is based on format of ymmdd which means 21/03/2001 and 1100 means 11:00:00.

input = [10321 1100;10322 1200;10323 1300]
output= {'21/03/2001 11:00:00';'22/03/2001 12:00:00';'23/03/2001 13:00:00'}

Subject: numbers to dates

From: Rune Allnor

Date: 18 Apr, 2010 09:28:08

Message: 2 of 5

On 18 apr, 10:31, enviro <farhadnejadkoo...@yahoo.co.uk> wrote:
> Hi there,
> How to convert numbers to dates. In the below 10321 is based on format of ymmdd which means 21/03/2001 and 1100 means 11:00:00.
>
> input = [10321 1100;10322 1200;10323 1300]

1) Extract dates, months and years from the number (Hint: The
   numbers always appear in the same order. Divide by 100 to
   move the 3rd digit to an easy-to-reach position.)
2) Use SPRINTF to reassemble the numbers on the desired format
3) Repeat for times.

And I wouldn't be surprised if something like DATESTR already
can do what you want.

Rune

Subject: numbers to dates

From: enviro

Date: 18 Apr, 2010 15:11:32

Message: 3 of 5

Could you give me an example?

Subject: numbers to dates

From: dpb

Date: 18 Apr, 2010 15:35:20

Message: 4 of 5

enviro wrote:
> Could you give me an example?

Could you show us what you've tried to do to implement one of Rune's
most excellent suggestions as to how to proceed?

--

Subject: numbers to dates

From: dpb

Date: 18 Apr, 2010 19:06:22

Message: 5 of 5

dpb wrote:
> enviro wrote:
>> Could you give me an example?
>
> Could you show us what you've tried to do to implement one of Rune's
> most excellent suggestions as to how to proceed?

Oh, and one more possibility to add to his list --

Convert to a character array and then parse it w/ (say) strread() and
let the rtl i/o library handle the scaling via judicious use of
formatting string(s).

num2str() might be useful here, in the first step...

It would seem wrapping this into a function would be _a_good_thing_ if
this occurs more than just once't or twice.

--

Tags for this Thread

No tags are associated with 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