MATLAB Answers

conversion of date from yyyymmddHHMMSS format to yymmddHHMMSS format.

8 views (last 30 days)
Remember Samu
Remember Samu on 13 May 2021
Edited: per isakson on 13 May 2021
Hi all can anyone please help with the conversion of date from yyyymmddHHMMSS format to yymmddHHMMSS format.
for example I want to change column 1 in the following dataset: (e.g row 1 shoud be 200723000000)
'2020,07,23,00,00,00' -0.800000000000000
'2020,07,23,00,00,10' -0.800000000000000
'2020,07,23,00,00,20' -0.700000000000000
'2020,07,23,00,00,30' -0.700000000000000
'2020,07,23,00,00,40' -0.700000000000000
'2020,07,23,00,00,50' -0.800000000000000
'2020,07,23,00,01,00' -0.700000000000000
'2020,07,23,00,01,10' -0.700000000000000
'2020,07,23,00,01,20' -0.700000000000000
'2020,07,23,00,01,30' -0.600000000000000
'2020,07,23,00,01,40' -0.600000000000000
'2020,07,23,00,01,50' -0.600000000000000
'2020,07,23,00,02,00' -0.500000000000000
'2020,07,23,00,02,10' -0.500000000000000
'2020,07,23,00,02,20' -0.500000000000000
'2020,07,23,00,02,30' -0.600000000000000
'2020,07,23,00,02,40' -0.500000000000000
'2020,07,23,00,02,50' -0.500000000000000
'2020,07,23,00,03,00' -0.500000000000000
'2020,07,23,00,03,10' -0.500000000000000
'2020,07,23,00,03,20' -0.500000000000000

Answers (1)

per isakson
per isakson on 13 May 2021
Edited: per isakson on 13 May 2021
vec = datevec( '2020,07,23,00,00,00', 'yyyy,mm,dd,HH,MM,SS' );
datestr( vec, 'yymmddHHMMSS' )
ans = '200723000000'
or did you mean
datestr( vec, 'yy,mm,dd,HH,MM,SS' )
ans = '20,07,23,00,00,00'
  7 Comments
Remember Samu
Remember Samu on 13 May 2021
Thank you so much Per, i needed to pass it in this format (datevec(T.DateTime(1:2,:),'yymmddHHMMSS')) and it worked!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by