Subject Re: [firebird-support] SQL conundrum
Author Ivan Prenosil
>> A time literal has to be of the format 'hh:nn:ss.xxxx'.
>
> This does exactly what I want (got the idea from your book, p. 158):
>
> select e.fullname, d.deptname, p.dayofweek, p.pchin,
> p.pchinloc, p.pchout, p.pchoutloc
> from pchup p
> join empinfo e on e.empno = p.empno
> join dept d on d.deptno = p.pchdept
> where (id > 305)
> and cast (p.PCHIN as date) between '2005/4/5' and '2005/4/7'
> and cast (extract (HOUR from p.pchin) as char(2))|| ':' ||
> cast (extract (MINUTE from p.pchin) as char(2))|| ':' ||
> cast (extract (SECOND from p.pchin) as char(7))
> between '13:00:00.0000' and '23:59:59.9999'

You can cast TIMESTAMP to both DATE and TIME (dialect-3 only):

where (id > 305)
and cast (p.PCHIN as date) between '2005/4/5' and '2005/4/7'
and cast (p.PCHIN as time) between '13:00:00.0000' and '23:59:59.9999'

Ivan
http://www.volny.cz/iprenosil/interbase/