matlab.datetime.compatibility.convertDatenum

Converts serial date numbers to datetime values.

Category: Language Fundamentals > Data Types

Syntax

t = matlab.datetime.compatibility.convertDatenum(d)

Returns the datetime array corresponding to the datenum values d.

Description

This helper is meant for code that still stores dates as serial numbers and has to feed them to functions that expect datetime. It is a thin wrapper for datetime(d, 'ConvertFrom', 'datenum'). The fractional part of each number becomes the time of day.

Input arguments

d
Numeric array of serial date numbers, as produced by datenum.

Output arguments

t
datetime array the same size as d.

Example

From datenum to datetime

matlab.datetime.compatibility.convertDatenum(738000.5)
Output
ans = datetime
   28-Jul-2020 12:00:00

See also

datetime datenum datestr posixtime