Subject | RE: [firebird-support] SELECT returns no data |
---|---|
Author | Svein Erling Tysvær |
Post date | 2011-05-31T06:35:06Z |
>I want to select data from '2011-05-29 15:00:00.0001' to '2011-05-30 14:59:59.9999'.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:
>
>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?
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