split numbers into coloumns
1 回表示 (過去 30 日間)
古いコメントを表示
Hello all
I have a raw of data with 16 digits like 0799569419940319, the last 8 digits are the year, the month and the day. How can I split the cells to extract the year and month and day?
4 件のコメント
Star Strider
2022 年 12 月 12 日
Consider:
n = 0799569419940319;
ns = num2str(n);
dn = ns(end-7:end) % Date Segment
nn = ns(1:end-8) % Number Segment
DT = datetime(dn, 'InputFormat','yyyyMMdd') % 'datetime' Vector
I hav no idea what the rest of these numbers are, so I cannot generalise this and so am not posting this as an Answer.
.
Jan
2022 年 12 月 12 日
The leading zero let me assume, that this is not a number, but a CHAR vector. But if it is really a number:
n = 0799569419940319;
day = rem(n, 100)
month = rem(floor(n / 100), 100)
year = rem(floor(n / 10000), 10000)
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!