Filter only specific month from date serial number

5 ビュー (過去 30 日間)
AA
AA 2017 年 3 月 16 日
回答済み: Peter Perkins 2017 年 3 月 16 日
Hi guys, I got a column with a date serial number and I would like to filter only the month of march. What is the coding for that?

採用された回答

Peter Perkins
Peter Perkins 2017 年 3 月 16 日
Unless you're using a version prior to R2014b, use datetimes:
>> dn = 736696 + 90*rand(10,1)
dn =
736755.016662924
736699.214051072
736772.421637528
736780.059392298
736757.086163937
736764.196611752
736762.881922131
736731.300431758
736754.993010116
736711.406801903
>> d = datetime(dn,'ConvertFrom','datenum')
d =
10×1 datetime array
01-Mar-2017 00:23:59
04-Jan-2017 05:08:14
18-Mar-2017 10:07:09
26-Mar-2017 01:25:31
03-Mar-2017 02:04:04
10-Mar-2017 04:43:07
08-Mar-2017 21:09:58
05-Feb-2017 07:12:37
28-Feb-2017 23:49:56
16-Jan-2017 09:45:47
>> (d.Month == 3)
ans =
10×1 logical array
1
0
1
1
1
1
1
0
0
0
Prior to 14b, use datevec.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by