简体   繁体   中英

Convert numerous date and time values into serial number

I need to convert date and time into a numerical value. for example:

>> num = datenum('2011-05-07 11:52:23')

num = 
   7.3463e+05

How would I write a script to do this for numerous values without inputting the date and time manually?

You can store your date strings first in a cell array (or a matrix, provided they are of fixed format), and feed it straight to datenum . For example:

C = {'2011-05-07 11:52:23'
     '2011-03-01 20:30:01'};
vals = datenum(C)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM