I am trying to calculate age as of a given YYYYMMDD date (2013-12-13) using an unsigned integer YYYYMMDD date of birth variable (dob) from a Sybase IQ 15.4 database (setdata). It isn't my database and I have no control over how the data are stored. I am using the following code:
select
convert(date,convert(varchar,dob)) as yearborn,
DATE("2013-12-31") as present,
datediff(month,yearborn,present)/12 as age_in_yrs
from setdata
This works fine in the Interactive SQL tool I have, but when I run it using SAS connect with the same code (so I can get a log) I get this message:
ERROR: CLI execute error: [Sybase][ODBC Driver][Sybase IQ]Data exception - data type conversion is not possible. -- (dfe_Cast.cxx 835)
Update: SAS converts the commands into ANSI SQL. So I think I am looking for an ANSI way to do this, and that my function is not supported.