Separate date and time

I have the datetime in a column as given in an attached example excel sheet. Between date and time there is an alphabet T. Can I get a help to seperate out date and time.
Thanks!

回答 (1 件)

Steven Lord
Steven Lord 2021 年 9 月 21 日

2 投票

dt = datetime('now') % Sample data
dt = datetime
21-Sep-2021 19:44:52
theTime = timeofday(dt)
theTime = duration
19:44:52
theDate = dt - theTime % or
theDate = datetime
21-Sep-2021
theDate2 = dateshift(dt, 'start', 'day')
theDate2 = datetime
21-Sep-2021

2 件のコメント

MatLab Code N
MatLab Code N 2021 年 9 月 21 日
I have also attached the example datetime along with the question. How can I make this work for my data?
MatLab Code N
MatLab Code N 2021 年 9 月 22 日
@Steven Lord any help is highly appreciated sir!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeTime Series Objects についてさらに検索

製品

リリース

R2019b

タグ

質問済み:

2021 年 9 月 21 日

コメント済み:

2021 年 9 月 22 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by