Last Sunday in a month?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Andreas Georgakakos
le 20 Fév 2018
Réponse apportée : Peter Perkins
le 20 Fév 2018
Hi there,
I am trying to identify the datetime of the last Sunday in March and October. I am aware of the nweekdate function but it requires the nth occurence of the day in that month, as an input. Any ideas would be highly appreciated.
Thank you in advance,
Andreas
0 commentaires
Réponse acceptée
Plus de réponses (1)
Peter Perkins
le 20 Fév 2018
Unless you are using a version of MATLAB prior to R2014b, use datetimes for dates, not numbers:
>> d = dateshift(datetime(2018,[3 10],1,'Format','eee, dd-MMM-yyyy'),'end','month')
d =
1×2 datetime array
Sat, 31-Mar-2018 Wed, 31-Oct-2018
>> d = dateshift(d,'dayofweek','sunday','previous')
d =
1×2 datetime array
Sun, 25-Mar-2018 Sun, 28-Oct-2018
0 commentaires
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!