Subject RE: [firebird-support] SELECT returns no data
Author Svein Erling Tysvær
>I want to select data from '2011-05-29 15:00:00.0001' to '2011-05-30 14:59:59.9999'.
>
>SELECT D, T, P, V FROM T_10199000
>WHERE D >= '2011-05-29' AND T >= '15:00:00.0001' AND D <= '2011-05-30' AND T <= '14:59:59.9999' ORDER BY D, T ASC;
>
>Apparently the above statment didn't work.
>
>Can someone change this correctly please?

I find this to be a funny, logical error, that Sean for some reason didn't notice. To see the error clearer, just remove the reference to the date in the where clause:

WHERE T >= '15:00:00.0001' AND T <= '14:59:59.9999'

Of course there is no value that is both smaller than 14:59 and at the same time greater than 15:00.

Here's two possible solutions that I think will work (at least one of them):

a)
SELECT D, T, P, V FROM T_10199000
WHERE (D = '2011-05-29' AND T >= '15:00:00.0001')
OR (D = '2011-05-30' AND T <= '14:59:59.9999')
ORDER BY D, T ASC;

b)
SELECT D, T, P, V FROM T_10199000
WHERE D+T between '2011-05-29 15:00:00.0001' and '2011-05-30 14:59:59.9999'
ORDER BY D, T ASC;

HTH,
Set