Search code examples
sqlinformix

How can i filter a datetime column in informix with a date


I'd like to filter a datetime column in informix 12.10.

I got the following "test" table

name insert_date create_date
... 2022-04-06 11:03:22.000 ....
... 2022-03-02 12:03:22.000 ....
... 2021-02-04 11:15:22.000 ....
... 2021-01-05 11:03:22.000 ....

My approach is the following

SELECT * FROM test where insert_date < "01.01.2022"

I got the error: SQL-Error [IX000]: Non-numeric character in datetime or interval.

How can i filter a datetime column with a date (without time) in informix?


Solution

  • According to the documentation that should be1

    select *
      from TEST
     where INSERT_DATE < DATETIME (2022-1-1) YEAR TO DAY
    

    1 Assuming that the data type of column INSERT_DATE is DATETIME YEAR TO FRACTION.