MATLAB: How do i convert the matlab date format, such as ‘2015-12-31’ to a date format 20151231, which is required as the Bloomberg End_Dt

MATLABmatlab date format to yyyymmdd

I am trying to pull data from Bloomberg, using the following.
d = getdata(c,'SPX Index','INDX_MEMBERS','End_DT', RebalanceDate)
However, it appears that Bloomberg requires the "RebalanceDate' field to be in the format of 'yyyymmdd'. My RebalanceDate is in Matlab format : 2015-12-31, for example.
Does anyone know how I can convert 2015-12-31 to 20151231?
Many thanks for your help.

Best Answer

  • datestr('2015-12-31','yyyymmdd')