# mjuliandate

Modified Julian date calculator

## Syntax

``mjd = mjuliandate(datetime)``
``mjd = mjuliandate(dateVector)``
``mjd = mjuliandate(dateCharacterVector,format)``
``mjd = mjuliandate(year,month,day)``
``dy = mjuliandate([year,month,day])``
``mjd = mjuliandate(year,month,day,hour,minute,second)``
``dy = mjuliandate([year,month,day,hour,minute,second])``

## Description

example

````mjd = mjuliandate(datetime)` converts one or more `datetime` arrays to modified Julian date, `mjd`. Modified Julian dates begin at midnight rather than noon, and the first two digits of its corresponding Julian date are removed.`mjd = mjuliandate(dateVector)` converts one or more date vectors, `dateVector`, to modified Julian date, `mjd`. `mjd = mjuliandate(dateCharacterVector,format)` converts one or more date character vectors, `dateCharacterVector`, to modified Julian date, `mjd`, using format `format`. ```

example

````mjd = mjuliandate(year,month,day)` and `dy = mjuliandate([year,month,day])` return the modified Julian date for corresponding elements of the `year,month,day` arrays. `mjd = mjuliandate(year,month,day,hour,minute,second)` and `dy = mjuliandate([year,month,day,hour,minute,second])` return the modified Julian date for corresponding elements of the `year,month,day,hour,minute,second` arrays. Specify the six arguments as one-dimensional arrays of the same length or scalar values.```

## Examples

collapse all

Calculate the modified Julian date for February 4, 2016 from `datetime` array.

```dt = datetime('04-02-2016','InputFormat','dd-MM-yyyy') jd = mjuliandate(dt) ```
```dt = datetime 04-Feb-2016 jd = 57422```

Calculate the modified Julian date for May 24, 2005 using date character version and `dd-mm-yyyy` format:

`mjd = mjuliandate('24-May-2005','dd-mmm-yyyy')`
```mjd = 53514```

Calculate modified Julian date for December 19, 2006 from year, month, and day inputs:

`mjd = mjuliandate(2006,12,19)`
```mjd = 54088```

Calculate the modified Julian date for October 10, 2004, at 12:21:00 p.m. using year, month, day, hour, month, and second inputs:

```mjd = mjuliandate(2004,10,10,12,21,0) ```
```mjd = 5.3289e+004```

## Input Arguments

collapse all

`datetime` array, specified as an m-by-1 array or 1-by-m array.

Full or partial date vector, specified as an m-by-6 or m-by-3 matrix containing m full or partial date vectors, respectively:

• Full date vector — Contains six elements specifying the year, month, day, hour, minute, and second

• Partial date vector — Contains three elements specifying the year, month, and day

Data Types: `double`

Date character vector, specified as a character array, where each row corresponds to one date, or a one-dimensional cell array of character vectors.

Data Types: `char` | `string`

Date format, specified as a character vector, string scalar, or integer. All dates in `dateCharacterVector` must have the same format and use the same date format symbols as the `datenum` function.

`mjuliandate` does not accept formats containing the letter `Q`.

If the format does not contain enough information to compute a date number, then:

• Hours, minutes, and seconds default to 0.

• Days default to 1.

• Months default to January.

• Years default to the current year.

Data Types: `char` | `string`

Year, specified as a scalar or one-dimensional array.

Dates with two character years are interpreted to be within 100 years of the current year.

#### Dependencies

Depending on the syntax, specify `year`, `month`, and `day` or `year`, `month`, `day`, `hour`, `minute`, and `second` as one-dimensional arrays of the same length or scalar values.

Data Types: `char` | `string`

Month, specified as a scalar or one-dimensional array from `1` to `12`.

#### Dependencies

Depending on the syntax, specify `year`, `month`, and `day` or `year`, `month`, `day`, `hour`, `minute`, and `second` as one-dimensional arrays of the same length or scalar values.

Data Types: `double`

Day, specified as a scalar or one-dimensional array from 1 to 31.

#### Dependencies

Depending on the syntax, specify `year`, `month`, and `day` or `year`, `month`, `day`, `hour`, `minute`, and `second` as one-dimensional arrays of the same length or scalar values.

Data Types: `double`

Hour, specified as a scalar from `0` to `24`.

#### Dependencies

Depending on the syntax, specify `year`, `month`, and `day` or `year`, `month`, `day`, `hour`, `minute`, and `second` as one-dimensional arrays of the same length or scalar values.

Data Types: `double`

Minute, specified as a double, whole number from `0` to `60`.

#### Dependencies

Depending on the syntax, specify `year`, `month`, and `day` or `year`, `month`, `day`, `hour`, `minute`, and `second` as one-dimensional arrays of the same length or scalar values.

Data Types: `double`

Second, specified as a double, whole number from `0` to `60`.

#### Dependencies

Depending on the syntax, specify `year`, `month`, and `day` or `year`, `month`, `day`, `hour`, `minute`, and `second` as one-dimensional arrays of the same length or scalar values.

Data Types: `double`

## Output Arguments

collapse all

Modified Julian date, returned as a column vector of m modified Julian dates, which are the number of days and fractions since noon Universal Time on January 1, 4713 BCE.

• m-by-6 column vector — Contains six elements specifying the year, month, day, hour, minute, and second

• m-by-3 column vector — Contains three elements specifying the year, month, and day

#### Dependencies

The output format depends on the input format:

Input Syntax`dy` Format
```mjd = mjuliandate(dateVector)```m-by-6 column vector or m-by-3 column vector of `m` modified Julian dates.
```mjd = mjuliandate(dateCharacterVector,format)```Column vector of m modified Julian dates, where m is the number of character vectors in `dateCharacterVector`.

## Limitations

The calculation of modified Julian date does not take into account leap seconds.

## Version History

Introduced in R2006b