I have a database table called My_table
with a column called timestamps
, which
contains the following data.
12-May-19
12-Jun-09
12-Apr-08
When I convert this timestamp to since 1970 using this sql query:
SELECT (timestamps - to-date(197001010000, 'yyyymmddhhss)×864) from My_table;
It returns a rounded up integer like 1459600 as expected on the ORACLE SQLPLUS terminal. However, if I execute the same query in an ORACLE Pro*C/C++ dynamic code which correctly set the data type as integer (selectda-T(i) = 2), it does not round up the results, it only truncate the results.
How can I get it to behave exactly the same as it is on the ORACLE SQLPLUS terminal?
Yeah, if you check the spec, Oracle says
INTEGER ... On output, if the column value is a real number, Oracle truncates any fractional part.
So if you want your integer rounded, you have to do it yourself in the SQL, e.g.
SELECT round(timestamps - to-date(197001010000, 'yyyymmddhhss')×864) from My_table;