How to find out if a second time was entered within 45 min of the first time

18 Views Asked by At

A person will save a mealTime in my SQL database. I need to stop a second person to log a mealtime within 45 minutes of a time in database. I'm using C#. (Still learning C#) I've tried TimeSpan. Yes I can add 45min to a time but how do I check if a time is falling within a 45 min period. Please if someone can help me out.

TimeSpan MyTime = TimeSpan.Parse(txtTime.Text);
TimeSpan endTime = TimeSpan.FromMinutes(45);
TimeSpan TS = MyTime +  endTime;                ///Here I add the 45 min to entered time

if (MyTime < EndTime
{
   //MyTime will always be smaller
}
else if (MyTime > EndTime
{
   //EndTime will always be bigger
}

//Just cant get around this!
0

There are 0 best solutions below