Hi there,

So I'm trying to come up with a formula which references a number based on a start date, start time and end time. Here is the table:

DATE STARTTIME ENDTIME CODE
2/5/11 12:00 AM 10:59 AM 0
2/5/11 11:00 AM 11:59 PM 1
2/6/11 12:00 AM 10:59 AM 1
2/6/11 11:00 AM 11:59 PM 2
2/7/11 12:00 AM 10:59 AM 2
2/7/11 11:00 AM 11:59 PM 3
2/8/11 12:00 AM 10:59 AM 3
2/8/11 11:00 AM 11:59 PM 4
2/9/11 12:00 AM 10:59 AM 4
2/9/11 11:00 AM 11:59 PM 5
2/10/11 12:00 AM 10:59 AM 5
2/10/11 11:00 AM 11:59 PM 6
2/11/11 12:00 AM 10:59 AM 6
2/11/11 11:00 AM 11:59 PM 7
2/12/11 12:00 AM 10:59 AM 7
2/12/11 11:00 AM 11:59 PM 8
2/13/11 12:00 AM 10:59 AM 8

Basically the first row says on 2/5, between 12:00 AM and 10:59 AM, the code should be zero.

On a separate sheet, I have values that I need to reference these tables with date and time. For example there are two relevant columns with date and time:
(A) (B) (C)
Date Time
(1) 2/11/11 6:45
(2) 2/5/11 2:57
(3) 2/5/11 12:41
(4) 2/5/11 23:46
(5) 2/6/11 5:59

Column "C" is where I need the codes populated. Since the first item is dated 2/11/11 at 6:45 the code should be 6. Can anyone help?