datetime

Methods

Method Reference: datetime.string

datetime: S = string (T)
datetime: S = string (T, fmt)

Convert datetime array to a string array.

S = string (T) converts the datetime array T to a string array S of the same size, formatting each element with the display format of T (its Format property). Not-A-Time (NaT) values become missing string elements.

S = string (T, fmt) formats each element with the Unicode (LDML) format fmt instead of the Format property of T (see char).

Source Code: datetime

string renders a datetime as a string array — using its display format, or a format you pass — and turns a NaT into a missing string.

 t = datetime (2024, 3, 9, 6, 0, 0)
t =
  datetime

   09-Mar-2024 06:00:00
 string (t)
ans =
  string

   "09-Mar-2024 06:00:00"
 string (t, 'yyyy-MM-dd')
ans =
  string

   "2024-03-09"
 string (NaT)
ans =
  string

   <missing>