busdays function not return correct date

33 Ansichten (letzte 30 Tage)
Yu Li
Yu Li am 8 Nov. 2024 um 0:16
Kommentiert: Walter Roberson am 8 Nov. 2024 um 4:25
Hi:
I'm trying to query the bus date list from given period, but I notice it returns different result by given the same date period, just at different time.
is there any mistake with my operation?
sample code is shown below:
load date_1
load date_2
load date_3
load date_4
busdays(date_1,date_2)
ans = 9x1 datetime array
28-Oct-2024 09:30:00 29-Oct-2024 09:30:00 30-Oct-2024 09:30:00 31-Oct-2024 09:30:00 01-Nov-2024 09:30:00 04-Nov-2024 09:30:00 05-Nov-2024 09:30:00 06-Nov-2024 09:30:00 07-Nov-2024 09:30:00
busdays(date_3,date_4)
ans = 8x1 datetime array
2024-10-28 10:30:00 2024-10-29 10:30:00 2024-10-30 10:30:00 2024-10-31 10:30:00 2024-11-01 10:30:00 2024-11-04 10:30:00 2024-11-05 10:30:00 2024-11-06 10:30:00
Thanks!
Yu

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 8 Nov. 2024 um 2:23
date_1 and date_2 both happen to have times of 09:30
date_3 has a time of 10:30. date_4 has a time of 9:30
The internal logic is
first_date : 1 : last_date
and then filter down to the business dates.
When the start time is 10:30 the generated times will all be 10:30 .
Note that date_4 itself will be excluded, since it's 9:30 time is after the 10:30 time of the starting time.
  2 Kommentare
Yu Li
Yu Li am 8 Nov. 2024 um 3:03
Bearbeitet: Yu Li am 8 Nov. 2024 um 3:04
this is really interesting, hmmmm.
steps are below shows how the difference is made:
load date_4
date_4
date_4-days(10)
the time difference between date_4-days(10) to date_4 is indeed 24*10 hours, the time difference is caused by transition from summer time to winter time recently in USA...
Walter Roberson
Walter Roberson am 8 Nov. 2024 um 4:25
I did not think of looking at time zones!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by