if option with weekend and date serial number
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
AA
le 28 Nov 2017
Réponse apportée : Walter Roberson
le 28 Nov 2017
I have a date serial number x. If the number is a weekend then x+3, if the number is not a weekend then x +1. how can i put this as code?
0 commentaires
Réponse acceptée
Walter Roberson
le 28 Nov 2017
output = x + 1 + 2 * isweekend( datetime(x, 'convertfrom', 'datenum') );
or
output = x + 1 + 2 * ismember(weekday(x), [1 7]);
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Dates and Time dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!