Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2025.0.0 - English


datevec

Date components

Syntax

V=datevec(DT)
[Y,M,D,H,MI,S]=datevec(DT)

Arguments

DT

a serial date number or datetime

Y, M, D, H, MI, S

year, month, day, hour, minute, second

those arguments can be real scalars or matrices of the same size.

Description

V = datevec(DT) converts a serial date number (defined by datenum) or a datetime to a date vector V having elements [year, month, day, hour, minute, second]. The first five vector elements are integers. DT can be an array.

[Y, M, D, H, MI, S] = datevec(DT) returns the components of the date vector as individual variables. DT can be an array.

Examples

// First example
datevec(720840)

// Second example
datevec(datenum())

// Third example (With integers values)
A = grand(10,12,'uin',1,1000000)
datevec(A)

// Fourth example (With real values)
A = grand(10,12,'unf',1,1000000)
datevec(A)

datevec with datetime

dt = datetime(["10/2/2024"; "12/25/2024"], "InputFormat", "MM/dd/yyyy");
datevec(dt)

See also

  • datenum — Convert to serial date number
  • calendar — Calendar of a given month and year (Gregorian dates)
  • datetime — create points in time

History

VersionDescription
2025.0.0 datevec allows a datetime as input argument.
Report an issue
<< datetime Time and Date duration >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Oct 24 11:13:10 CEST 2024