DateTime startDay = DateTime.Now.Date; // Choose any date you want to get that Day at 00:00 DateTime startDay530pm = startDay.AddHours(17.5); // Set the time of Day. Use .Addxxx where xxx might be hours, mins, etc DateTime nextDay7am = startDay.AddDays(1).AddHours(7); // Adds 1 full day (24 hours) from 00:00 and any additional time next day DateTime whenever = DateTime.Now; // Choose any DateTime you want to check bool IsInsideTimes = whenever >= startDay530pm && whenever < nextDay7am; bool IsOutsideTimes = whenever < startDay530pm || whenever >= nextDay7am;
Thanks.
Comment