In my requirement, I need to take the difference between date time by milliseconds. its most of the time receiving correctly, but in sometimes, it shows minus value.
in my table I'm storing EXPIREDDATE
as follows, to update EXPIREDDATE time by 2 hours
UPDATE nd_user_encode_keys
SET EXPIREDDATE = SYSDATE + ( 1 / 1440 * 120) -- here 120 means 2 hours
and according to my SP, above query running before the below query.
SELECT (EXPIRYDATETIME - SYSDATE) * 24 * 60 * 60 * 1000 as EXPIRYDATETIMEINMILISECONDS
My problem is most of the time result is 7200000 , but somtimes it shows minus value like this -34932000 . what could be the reason for this issue. can someone please explain.
When you have A - B
, then the result can be:
A = B
A > B
A < B
--> that is your caseWhy is expirydatetime
less than sysdate
and is that a valid value, I wouldn't know, but you should as it is your database, you're storing values into that table.
According to update
statement you posted, and regarding the fact that sysdate
won't return the same value "right now" as it did "a few moments ago", then it depends on when you ran that update
.
Therefore, I presume it is about time difference between update
and select
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.