using System.Collections.Generic;
public static void Main()
var startDate = new DateTime(2020, 9, 1);
var endDate = new DateTime(2020, 9, 30);
var daysInMonth = DateTime.DaysInMonth(fileYear, fileMonth);
Console.WriteLine(daysInMonth);
var hoursInMonth = daysInMonth * 24;
Console.WriteLine(hoursInMonth);
if (startDate.Year == fileYear &&
startDate.Month == fileMonth &&
startHour = (startDate.Day - 1) * 24;
var timeIndices = Enumerable.Range(startHour, hoursInMonth - startHour);
if (endDate.Year == fileYear &&
endDate.Month == fileMonth &&
endDate.Day != daysInMonth)
var endHour = endDate.Day * 24;
timeIndices = timeIndices.Where(x => x < endHour);
Console.WriteLine(timeIndices.Count());
Console.WriteLine(string.Join(", ", timeIndices));