Datetime vs Long
Posted in 1995
Topics: Performance & Tuning, Connectivity: ESQL/C, 4GL & Embedded SQL
Jon > I have some developers working on an OLTP application, and a question > was asked, that I could not answer. My hope, is that someone on the net > will enlighten me. > > Given the application is being developed in ESQL/C, with Tuxedo and Online: > > 1.) Am I better off to store and manipulate date/times using 'datetime' or > using an integer or long and performing the math. Is the use of datetime, a > performance issue?? My feeling is no. We use the UNIX time_t which is an signed long. This therefore gives us seconds before and after 01/01/1970. It stretches all the way from approx 1910 to 2030+. By then hopefully I will not be programming anymore. On a more serious note, the arithmetic manipulation of time_t is much easier than arithmetic operations on datetime. The UNIX operating system also uses time_t. With datetime you will be able to use dates before 1910 and after 2030. Performance should not be a problem with datetime. All the arithmetic is on integers. > > 2.) Decimal vs. integer, for storing dollar amounts. Because manipulation of > decimal in C, is a little messy, should we avoid using and storing decimal, and > stick to integer(s) and perform the math?? We use double with rounding. Informix esql/c provides automatic conversion from double to sql decimal and back in it's binding routines. I would not advise integers unless you have a 64bit integer. Think of the third world currencies and third world inflation. Theo theo@rascal.co.za