Round Dates and Times

버전 1.6.5 (8.04 KB) 작성자: Stephen23
Round dates/times to the selected unit (round/floor/ceiling).
다운로드 수: 1.3K
업데이트 날짜: 2020/11/30

라이선스 보기

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].

datevec(dateround(730123.62972287962))
ans = [1999,1,3,15,6,48]

datevec(dateround([1999,1,3,15,6,48.0568]))
ans = [1999,1,3,15,6,48]

datevec(dateround([1999,1,3,15,6,48.0568],'minute'))
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]

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

datevec(dateround([1999,12,31,23,59,59.5000;1999,12,31,23,59,59.4999]))
ans = [2000,1,1,0,0,0;1999,12,31,23,59,59]

인용 양식

Stephen23 (2024). Round Dates and Times (https://www.mathworks.com/matlabcentral/fileexchange/39274-round-dates-and-times), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2010b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.6.5

* Improve summary

1.6.4

* Add error IDs.

1.6.3.0

* Update FEX screenshot

1.6.2.0

* Update screenshot

1.6.1.0

* Update FEX screenshot

1.6

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

1.5.0.0

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

1.4.0.0

- Revert conversion precision adjustment to original value.

1.3.0.0

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

1.2.0.0

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

1.1.0.0

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

1.0.0.0