I have a service that user can configure to run during \"off-peak\" hours. They have the ability to set the time frame that the service can run.
For Example:
DateTime t1;
t1 = DateTime.Now;
// loop inbetween start and end time
if (t1>=start_time &&t1<=end_time)
{
//your code / action
}
//if you are using sql to get values
start_time = Convert.ToDateTime(row.Cells[10].Text);
end_time = Convert.ToDateTime(row.Cells[11].Text);
//convert them to string or you will get some error!!!