Re: Compare 2 dates
Posted in 1999
On Wed, 27 Jan 1999, SoftTeam Blas Catherine wrote: > I want to know if there is a function which can compare 2 dates in a SQL > statement, In fact, The equivalent of DateDiff used in SQL Server. What sort of comparison does DateDiff do? In Informix's dialect of SQL using the DATE type, you can do: WHERE date1 > date2 -- or any of the other comparators >=, <, <=, <>, !=, = WHERE date1 - date2 > 30 -- meaning where date1 is more than 30 days later than date2 WHERE date1 > date2 + 30 -- also meaning where date1 is more than 30 days later than date2 There are no direct function calls required for these. If you want to play with DATETIME types, then the comparisons work the same as DATE provided the types of the operands are the same, but DATETIME arithmetic obeys somewhat different (and much more complex) rules, as do mixed type comparisons. Nevertheless, you can probably do whatever you want -- we just need to be told what the DateDiff function does, given sample inputs and the corresponding outputs. Yours, Jonathan Leffler (jleffler@informix.com) #include <wish/I/was/skiing.h> Guardian of DBD::Informix v0.60 (v0.61_02) -- http://www.perl.com/CPAN Informix IDN for D4GL & Linux -- http://www.informix.com/idn