title: Why comparing Timestamp and date in Firebird result in weird value?
body: <p>I'm comparing some dates and times and found that I do not understand <a href="http://www.firebirdsql.org/en/firebird-date-literals/" rel="nofollow">Firebird Date Literals</a> and <a href="http://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-datatypes-conversion.html" rel="nofollow">their conversions</a> as I thought so.</p>
  
  <p>Please, see this query:</p>
  
  <pre><code>SELECT 
      iif('2016-01-25' &lt;= '2016-01-25', 1, 0) AS TSCASE,
      iif('2016-01-25 00:00:00.000' &lt;= '2016-01-25', 1, 0) AS TSCASE1,
      iif('2016-01-25 00:00:00.000' &lt;= cast('2016-01-25' as timestamp), 1, 0) AS TSCASE2,
      iif(cast('2016-01-25 00:00:00.000' as timestamp) &lt;= '2016-01-25', 1, 0) AS TSCASE3,
      iif('2016-01-25 00:00:00.000' &lt;= '2016-01-25 00:00:00.000', 1, 0) AS TSCASE4,
      iif('2016-01-25 00:00:00.000' &lt;= '2016-01-25 23:59:59.999', 1, 0) AS TSCASE5,
      iif('2016-01-25 00:00:00.000' &lt;= '2016-01-25  23:59:59.999', 1, 0) AS TSCASE6,
      iif('2016-01-25 00:00:00.000' &lt;= cast('2016-01-25  23:59:59.999' as timestamp), 1, 0) AS TSCASE7
  FROM RDB$DATABASE
  </code></pre>
  
  <p>I'm expecting that every column result was 1. But this is the result:</p>
  
  <pre><code>TSCASE  TSCASE1 TSCASE2 TSCASE3 TSCASE4 TSCASE5 TSCASE6 TSCASE7
         1      0       1       1       1       1       0       1
  </code></pre>
  
  <p>So why <code>'2016-01-25 00:00:00.000' &lt;= '2016-01-25'</code> is false but, when I do any <code>cast</code> to <code>TIMESTAMP</code>, is true?</p>
  
  <p>Also why <code>'2016-01-25 00:00:00.000' &lt;= '2016-01-25 23:59:59.999'</code> and <code>'2016-01-25 00:00:00.000' &lt;= cast('2016-01-25  23:59:59.999' as timestamp)</code> are true, but <code>'2016-01-25 00:00:00.000' &lt;= '2016-01-25  23:59:59.999'</code> is false? </p>
  
  <p>Please note the extra space between the date and time in these last two expressions. I did think that the extra space would not change the result as you can see in this quote also from the <a href="http://www.firebirdsql.org/en/firebird-date-literals/" rel="nofollow">first link</a>:</p>
  
  <blockquote>
    <p>White Space in Date Literals</p>
    
    <p>Spaces or tabs can appear between elements. A date part must be separated from a time part by at least one space.</p>
  </blockquote>