Parse variable in a table
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Inna Pelloso
am 8 Aug. 2023
Kommentiert: Star Strider
am 8 Aug. 2023
Hi,
I have a variable in a table, timestamp, in the following format:
2023-02-24 13:00:00
How can I parse this variable into two new variables, date (2023-02-24) and time (13:00:00)?
Any help would be appreciated!
IP
0 Kommentare
Akzeptierte Antwort
Star Strider
am 8 Aug. 2023
Bearbeitet: Star Strider
am 8 Aug. 2023
Several options, depending on what you want —
timestamp = '2023-02-24 13:00:00'
DT = datetime(timestamp)
Date = DT;
Time = DT;
Date.Format = 'yyyy-MM-dd'
Time.Format = 'HH:mm:ss'
Date = extractBefore(timestamp, ' ')
Time = extractAfter(timestamp, ' ')
DateTime = strsplit(timestamp, ' ')
.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!