How to count number of days within datetime array

9 views (last 30 days)
I have a timetable which spans a year. The intervals between the datetimes varies from one minute to ten minutes. I am interested in finding out how many days contain any data at all. I tried using histogram but this returns an empty bin on days in which there was no data collected, and so conflates days where there was data collected but the values were 0, and data where there was no data collected.
This seems like it should be simple but I am sorry I can't figure it out!

Accepted Answer

Kanupriya Singh
Kanupriya Singh on 9 Jul 2020
Since your previous attempts are returning you empty data for days that are not in your datetime array, you could calculate the number of days that have any data by using this function-
This will return you the number of non-zero elements in the array.
Louise Wilson
Louise Wilson on 9 Jul 2020

Sign in to comment.

More Answers (1)

madhan ravi
madhan ravi on 8 Jul 2020
Use retime() with 'daily' 'count' .
  1 Comment
Louise Wilson
Louise Wilson on 8 Jul 2020
Thanks for your response Madhan. I tried this:
but it does the same as my attempt above. It lists all days between the first datetime and last datetime in my timetable, and so creates rows for datetimes that never existed in my timetable in the first place.

Sign in to comment.


Find more on Data Type Conversion in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!