Min’s issue here is that the database fields are not from the Natural D format, so it is not getting the benefit of built-in typecasting to other date formats. Programmatically the values are expressed as YYYYMMDD but to both Natural and Adabas these are just any N8/P8/U8 number.
I am not sure how you can fix this, Min. Had it been a DDM that used Natural’s D format, you wouldn’t have this problem.
I did tried changing the native type to Text Date(YYYYMMDD) in the CDD Data Dictionary tool after the import. While this allows me to do the select with timstampdiff, the change in the data type gives me an adabas resp code 44 when I tried to insert/update a value into this column. Resp code 44 is pointing to format buffer error.
My update looks like this:
update table_name set date_value_column_name = ‘20110304’ or
update table_name set date_value_column_name = 20110304