TIMESTAMP arithmetic
The TIMESTAMP
data type and related arithmetic work differently from how it may seem at first glance. Let’s take the TIMESTAMP
value and add 1 day, represented by adding the value 1
to the particular value. However, what about the output? Will it even work? The following statement provides you with the answer:
select localtimestamp, localtimestamp + 1 from dual;
In addition, the following table shows the results:
LOCALTIMESTAMP |
LOCALTIMESTAMP + 1 |
13.06.22 07:08:49,847000000 |
14.06.2022 07:08:49 |
Table 5.4 – Timestamp arithmetic
Yes, it took the localtimestamp
value and added 1 day. The result is, however, a bit strange, isn’t it? Namely, the second fractions are lost. What has happened? Well, particular addition and subtraction cannot be applied to the TIMESTAMP
value. To prevent...