Advice needed with the dateshift function
Mostrar comentarios más antiguos
I'm struggling with the dateshift function and need some help if anyone can offer it.
I need to write some code that, once a menu option is chosen, will provide the next of two dates. i.e. If option 1 is selected on the menu, then either the next sunday date is displayed or the next wednesday date, whichever is nearest.
I can display the next sunday date, AND the next wednesday date, but i can't display the next sunday OR the next wednesday.
1 comentario
Michael T
el 12 de Abr. de 2019
Respuestas (3)
Walter Roberson
el 12 de Abr. de 2019
days_to_shift_Sw = [0 2 1 0 3 2 1]
days_to_shift_Sw( day(t, 'dayofweek') )
4 comentarios
Michael T
el 13 de Abr. de 2019
Walter Roberson
el 13 de Abr. de 2019
Add that number of days to the current date.
Question though: if it is already Sunday, then should the date stay the same, or should it be the next Wednesday ?
Michael T
el 13 de Abr. de 2019
Walter Roberson
el 13 de Abr. de 2019
Okay, so just add the indicated number of days to the current day.
AMAN GARG
el 27 de Jul. de 2020
0 votos
dayshift(x,'Start','Hour')
Steven Lord
el 27 de Jul. de 2020
N = datetime('today')
W = dateshift(N, 'dayofweek', 'Wednesday')
S = dateshift(N, 'dayofweek', 'Sunday')
answer = min(W, S)
Categorías
Más información sobre Dates and Time en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!