Pete,
Hope you don't mind these further questions...
On the back of what you provided below, I have now been asked to
expand on what I have at the moment. The idea is as follows:
The spreadsheet has a start and end date / time. If:
1. The start & end dates are the same day, and the start & end times
are between 08:00 & 17:00, a 1 should be entered in the field
IF(AND(MOD(H2,1)<17/24,MOD(G2,1)>8/24),"1","N")
2. If the start time is between 08:00 & 17:00, but the end time is
after 17:00 but before 08:00 the following morning, a 2 should be
entered in the field
IF(AND(MOD(G3,1)>8/24,MOD(H3,1)>17/24),"2","N")
3. If the start time is after 17:00 but before 08:00 the next day, and
end time is between 08:00 & 17:00, a 3 should be entered in the field
IF(AND(MOD(G4,1)>17/24,MOD(H4,1)<24/24),"3","N")
4. If the start time is after 17:00 on a Friday and the end time is
before 08:00 on the Monday, a 4 should be entered in the field
IF(AND(WEEKDAY(G5, 2)>=6, WEEKDAY(H5, 2)<=7), 4, 0)
5. If the start time is after 17:00 and the end time is before 08:00
the following day, a 5 should entered in the field
IF(AND(WEEKDAY(G6, 2)>=6, WEEKDAY(H6, 2)<=7), 5, 0)
Complicated!!
I don't know if the formulae I've listed are right, so perhaps you
could look them over. What I'm now worried about is combining them
all into the one cell. If I combine them, I get:
=IF(AND(MOD(H2,1)<17/24,MOD(G2,1)>8/24),"1",IF(AND(MOD(G3,1)>8/24,MOD(H3,1)>17/24),"2",IF(AND(MOD(G4,1)>17/24,MOD(H4,1)<24/24),"3",IF(AND(WEEKDAY(G5,
2)>=6, WEEKDAY(H5, 2)<=7), 4, IF(AND(WEEKDAY(G6, 2)>=6, WEEKDAY(H6,
2)<=7), 5, "")))))
However, this can't be right. When I have:
Start End
Fri 01/01/10 12:15 Fri 01/01/10 19:00
This gives a result of 4, "If the start time is after 17:00 on a
Friday and the end time is before 08:00 on the Monday", when it should
be 2, "If the start time is between 08:00 & 17:00, but the end time is
after 17:00 but before 08:00 the following morning"
Can you cast your eye over things and let me know what I'm doing
wrong?
Many thanks
Duncs