Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2025.0.0 - Русский


datenum

Convert to serial date number

Syntax

N = datenum()
N = datenum(DT)
N = datenum(Y, M, D)
N = datenum(Y, M, D, H, MI, S)

Arguments

DT

m-by-3 matrix, [Y, M, D] or m-by-6 matrix, [Y, M, D, H, MI, S] 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

The datenum function converts date vectors (defined by datevec) into serial date numbers. Date numbers are serial days elapsed from some reference date. By default, the serial day 1 corresponds to 1-Jan-0000.

N = datenum() returns the serial date numbers corresponding to current date.

N = datenum(DT) converts one or more date vectors to serial date number N. DT can be an m-by-6 or m-by-3 matrix containing m full or partial date vector respectively or a datetime.

N = datenum(Y, M, D) returns the serial date numbers for corresponding elements of the Y, M, and D (year, month, day) arrays. Y, M and D must be arrays of the same size (or any can be a scalar).

N = datenum(Y, M, D, H, MI, S) returns the serial date numbers for corresponding elements of the Y, M, D, H, MI, and S (year, month, day, hour, minute, and second) array values.Y, M, D, H, MI, and S must be arrays of the same size (or any can be a scalar).

Examples

// N = datenum()
datenum()

// N = datenum(DT)
A = [ 0 1 1 0 0 0 ; 2005 2 8 21 37 30 ]
datenum(A)

// N = datenum(Y, M, D)

Years = [0; 1973; 2006]
Months = [1; 8; 2]
Days = [1; 4; 8]
datenum(Years,Months,Days)

Years = [0 0 0 ; 0 0 0]
Months = [1 1 1 ; 1 1 1]
Days = [1 2 3 ; 4 5 6]
datenum(Years,Months,Days)

// N = datenum(Y, M, D, H, MI, S)

Years = grand(5,10,'uin',0,2006)
Months = grand(5,10,'uin',1,12)
Days = grand(5,10,'uin',1,28)
Hours = grand(5,10,'uin',0,23)
Minutes = grand(5,10,'uin',0,59)
Seconds = grand(5,10,'uin',0,59)
datenum(Years,Months,Days,Hours,Minutes,Seconds)

datenum with datetime

dt = [datetime(2024, 10, 2, 15, 35, 26); datetime(2024, 12, 25)]
datenum(dt)

See also

  • datevec — Date components
  • calendar — Calendar of a given month and year (Gregorian dates)

History

ВерсияОписание
2024.1.0
  • Values out of 1:12 for M (month) and out of 1:31 for D (day) are now managed.
  • datenum() contains milliseconds information.
2025.0.0 datenum allows a datetime as input argument.
Report an issue
<< date Time and Date datetime >>

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:18:33 CEST 2024