Thanks again ceinma.
With that I've created my own Informix version of TIMESTAMPDIFF supporting DAY, MONTH and YEAR (all that I require - for now...).
>>>
create function timestampdiff (type char(20), pDate1 datetime year to second, pDate2 datetime year to second) returning integer;
if type = 'SQL_TSI_DAY' then
return date(pDate2) - date(pDate1);
elif type = 'SQL_TSI_MONTH' then
return (month(pDate2) - month(pDate1)) + ((year(pDate2) - year(pDate1)) * 12);
elif type = 'SQL_TSI_YEAR' then
return year(pDate2) - year(pDate1);
end if;
end function
<<<
And so when running Informix my runtime parser extracts "{fn TIMESTAMPDIFF(SQL_TSI_DAY, createddate, receiveddate)}" and places quotes around SQL_TSI_DAY in order to call my function.
One last quick question, you can see I've had to pass SQL_TSI_DAY as a string - do you know if it is possible to globally define such variables in Informix? If it is then I would not have to alter the SQL string at all at runtime.
thanks
Andy