Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Datetick format

Datetick format

Datetick format


I am importing some data from excel, on my file the format for the date is dd/mmm/yyyy HH:MM:SS.
Datetick format needs to have it dd-mmm-yyyy HH:MM:SS.

Can someone please help me on how can I convert it to the datetick format please.


RE: Datetick format

Replace "/" with "-".

RE: Datetick format

... using something like strrep().

- Steve

RE: Datetick format

There are two ways to do this.

(1) Easier

Change the date format in excel itself....

format cells-> select custom --> (type the format you need)

your case dd-mmm-yyyy HH:MM:SS

then read this file

(2) Round about way

lets say your excle file first column contians date in any format and second column contains numbers. Save the file in csv format and use textscan command(i believe you cannot read strings using xlsread command)

fileformat='%s %f';

Assuming your first and second rows contain some headings/units 'headerlines',2 will ignore first  two rows.

Now 'Data' is a cell data type with Data{1} containing array of date strings

dateformat='dd-mmm-yyyy HH:MM:SS'  % Could be any format

%====if you want to plot use
datetick(dateformat)  % Will put your dates in required format on axis

% ==if you want to rewire formatted strings to excel file==

ReqDates will contain a string of dates in required format
you can drirectly write/overwrite these dates to you excel file using xlswrite('Filename.xls',ReqDates,'Worksheet','Range');

Hope this helps.

Nodal DOF


RE: Datetick format

thanks Nodal and sompting
I will try it!


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close