Trying to compare a given Time between two times to see if it's within the those intervals. e.g. if given Time is 00:00 I need to find out if it falls between 21:00:00 to 7:00:00. Tried TimeSpan.Compare no lock and also used > or < for Time Part.
e.g.
Given Intervals:
7:00:00 to 19:00:00
19:00:00 to 21:00:00
21:00:00 to 7:00:00
Times to compare:
00:00:00 and 01:00:00
Any help will be appreciated.
Updated Question:
Looks like the requirement is quiet vague. The requirement is basically to pass the Time (TimeSpan) and compare with two TimeSpan intervals to see if they fall in to the those interval.
e.g. Lets say employees get different allowances if they work on different time slots below:
Date Range: 2012-01-01 to 2012-31
19:00:00 to 21:00:00 ($10.00)
21:00:00 to 7:00:00 ($11.00)
7:00:00 to 19:00:00 ($12.00)
To calculate the hourly rate for an employee I need to check whether the employee has worked
- Between Date Range :2012-01-01 to 2012-31
- Between Time Range above.
And apply $ Rate accordingly.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…