>>>>>the following code in a SQL interrogation always return "0-12"
>>>>>
>>>>>
>>>>>IIF( (HOUR( TTOD( Table1.datecreation)) >=0 AND HOUR( TTOD( Table1.datecreation)) <= 11), "0-12", IIF( (HOUR( TTOD( Table1.datecreation)) >= 12 AND HOUR( TTOD( Table1.datecreation)) <= 15), "12-16", "16-24")) as HourBlock
>>>>>
>>>>>
>>>>>Data contains hours in all the range 0-24. So I should have some "12-16" and "16-24"
>>>>>
>>>>>You guys see something that I don't?
>>>>
>>>>What's Set('hour')? Hint: it should be 24 in your case.
>>>
>>>I thought about it but the help says that "set hours" doesn't make a difference.
>>
>>I don't see that in help, may I ask where you see it? Anyway, I would try Set Hour = 24 and see what happens to your query.
>
>from my help file
>
>HOUR( ) returns a numeric value based on a 24 hour format, and is not affected by the current setting of SET HOURS. For example, if SET HOURS is 12 or 24, the following command returns 13:
>
>? HOUR({^1998-02-16 1:00p})
>
>
>And I just tried with set hours 24 and I got the same results.
OK, I see it now. Anyway, I think Sergey nailed why you get the wrong result. And by the way, you should check Between() in help, it will make your code shorter and easier.to read.