フィルターのクリア

Function for day of the year

10 ビュー (過去 30 日間)
amateurintraining
amateurintraining 2017 年 10 月 11 日
編集済み: per isakson 2017 年 10 月 11 日
How do I write a function that responds the days of the year when given a certain date? For example, January 7th, 2017 would respond 7 as that is the 7th day of the year. (This is also accounting for leap years.)

採用された回答

per isakson
per isakson 2017 年 10 月 11 日
編集済み: per isakson 2017 年 10 月 11 日
Introduced in R2014b
>> day( datetime('07-Jan-2017', 'InputFormat', 'dd-MMM-yyyy' ), 'dayofyear' )
ans =
7
"accounting for leap years" If not, shame on The MathWorks!
>> day( datetime('01-Mar-2017', 'InputFormat', 'dd-MMM-yyyy' ), 'dayofyear' )
ans =
60
>> day( datetime('01-Mar-2016', 'InputFormat', 'dd-MMM-yyyy' ), 'dayofyear' )
ans =
61

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by