Reading string formatted Date and Time from CSV
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi
I have csv files with the following format of date and time:
"Saturday, 12 February 2022 22:00:12"
Obviously this just one of the columns in the file, with additional data in adjacent columns. How can this be read into usable date and time data?
Thanks
댓글 수: 0
채택된 답변
Star Strider
2022년 2월 18일
‘Obviously this just one of the columns in the file, with additional data in adjacent columns. How can this be read into usable date and time data?’
str = "Saturday, 12 February 2022 22:00:12";
dt = datetime(str, 'InputFormat',"eeee, d MMMM yyyy HH:mm:ss")
See the datetime documentation section on infmt ('InputFormat') for more examples and an extended discussion. See the Format section to understand how to set the display format for the array datetime produces.
Replace ‘str’ here with the column reference to your table.
.
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
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!