Main Content

yyyymmdd

ConvertMATLABdatetime to YYYYMMDD numeric value

Description

example

d = yyyymmdd(t)返回一个doublearray containing integers whose digits represent the datetime values int. For example, the date July 16, 2014 is converted to the integer 20140716. The conversion is performed this way:

d = 10000*year(t) + 100*month(t) + day(t)

Examples

collapse all

Create an array of YYYYMMDD numeric values that represent dates.

d = [20140628 20140701 20140704]
d =1×320140628 20140701 20140704

Convert the dates to datetime values.

t = datetime(d,'ConvertFrom','yyyymmdd')
t =1x3 datetime28-Jun-2014 01-Jul-2014 04-Jul-2014

Convert the datetime values back to YYYYMMDD numeric values.

d2 = yyyymmdd(t)
d2 =1×320140628 20140701 20140704

Input Arguments

collapse all

Input date and time, specified as adatetimearray.

Extended Capabilities

版本;n History

Introduced in R2014b