Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

yyyymmdd

Convert MATLAB datetime to YYYYMMDD numeric value

Syntax

d = yyyymmdd(t)

Description

example

d = yyyymmdd(t) returns a double array containing integers whose digits represent the datetime values in t. 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 = 

    20140628    20140701    20140704

Convert the dates to datetime values.

t = datetime(d,'ConvertFrom','yyyymmdd')
t = 1x3 datetime array
   28-Jun-2014 00:00:00   01-Jul-2014 00:00:00   04-Jul-2014 00:00:00

Convert the datetime values back to YYYYMMDD numeric values.

d2 = yyyymmdd(t)
d2 = 

    20140628    20140701    20140704

Input Arguments

collapse all

Input date and time, specified as a datetime array.

Extended Capabilities

Introduced in R2014b

Was this topic helpful?