Round Dates and Times

Versión 1.6.5 (8.04 KB) por Stephen23
Round dates/times to the selected unit (round/floor/ceiling).

1.2K descargas

Actualizado 30 Nov 2020

Ver licencia

This function rounds datetime or serial date numbers or date vectors to the nearest year, month, day, hour, minute, or second. With a choice of rounding, floor, or ceiling.

### Examples ###

Examples use the date+time described by the vector [1999,1,3,15,6,48.0568].

ans = [1999,1,3,15,6,48]

ans = [1999,1,3,15,6,48]

ans = [1999,1,3,15,7,0]

datevec(dateround([1999,1,3,15,6,48.0568],5)) % 5=='minute'
ans = [1999,1,3,15,7,0]

ans = [1999,1,3,15,6,0]

ans = [2000,1,1,0,0,0;1999,12,31,23,59,59]

Citar como

Stephen23 (2023). Round Dates and Times (, MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2010b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión

* Improve summary


* Add error IDs.

* Update FEX screenshot

* Update screenshot

* Update FEX screenshot


* Fixed orientation bug.
* Supports datetime inputs.
* Added HTML documentation.

* Make string arguments case insensitive.
* Improve input argument checking.

- Revert conversion precision adjustment to original value.

- Fixed incorrect order when rounding multiple dates.
- Improve internal precision management.

- Now only returns Date Numbers. This simplifies the code and the help comments.

- Fix bug in 'ceiling'.
- Unit tokens changed to match datestr8601/datenum8601 tokens.
- Simplify date format selection code.