In reply to JJL:
> T=1 is always first day
OK, then it seems to me that, since it looks like there can never be more than 24 hours between arrival and departure and T is always on the first day, then when D < A you only need to test for T >= A, otherwise test for (T >= A) AND (T <= D).
This pseudoformula might do it...
=if(OR(AND(A<D, T>=A, T<=D),AND(A>D, T>=A)),"Y","N")