ESQL\\C and datetime manipulations
Posted in 1995
Topics: SQL Development & Query Writing, Connectivity: ESQL/C, 4GL & Embedded SQL
Hi All, I am trying to manipulate arithmetically the datetime variables. It was easy in 4GL where all i have to do is say variable_a = variable_b + 5 UNITS HOUR to add 5 hours to a datetime variable defined as year to second. It is not that easy in ESQL/C. ESQL version 7.1 seems to have a function called dtaddinv() where i can add a interval to a datetime field. But i am using version 4.1 which doesn't have a function like that. The workaround i have is thru a SQL query. Something like SELECT variable_b + 5 UNITS HOUR from table_a. This will work as long as the table contains at least one row. (This SQL query doesn't refer to any field in the table). Of course this is done thru a PREPARE and variable_b is passed as a parameter during OPEN. Is there a better way to do it ?. Also I need to compare 2 datetime variables to determine which is greater. There is no function to do this also. The workaround i have is convert the datetime to string and do a strcmp(). Shouldn't there be a better way ?. If you think there is one, please e-mail me at skperin@wal-mart.com or skperin@delphi.com. Or post it here. Thanks. Sudhir Perinchery P.S. I am relatively new to ESQL/C. Maybe i am missing something.