The calculation time difference is a common problem with Oracle Data data types. Oracle Support Date Calculation, you can create expressions such as "Date 1-Date 2" to calculate the time difference between the two dates.
Once you have discovered time difference, you can use simple skills to calculate the time difference with days, hours, minutes, or seconds. In order to get the data poor, you must choose the appropriate time measurement unit so that you can hide the data format. The conversion date is a temptation using a complete complex conversion function, but you will find that this is not the best solution.
Round (to_number (end-date-start_date)) - Eladed Time (in Sky) Round (TO_NUMBER (End-Date-Start_Date) * 24) - Eladed Time (in Hours) Round (TO_NUMBER (END- Date-start_date) * 1440) - Time (in minutes)
What is the default mode of display time difference? In order to find the answer to this question, let us conduct a simple SQL * PLUS query.
SQL> SELECT SYSDATE- (sysdate-3) from dual; sysdate- (sysdate-3) ------------------- 3
Here, we have seen Oracle uses the sky to use the unit as a lost time, so we can easily use the conversion function to convert it into hours or minutes. However, when the number of minutes is not an integer, we will encounter the problem of placing a decimal point.
SELECT (sysdate- (sysdate-3.111) * 1440from dual;
Of course, we can solve this problem with the Round function (ie, a finifier), but to remember that we must first convert the Date data type into Number data type.
Select Round (to_number (sysdate- (sysdate-3.111)) * 1440) from Dual; Round (to_number (sysdate- (sysdate-3.111)) * 1440) ---------------- ------------------------------ 4480 (sysdate- (sysdate-3.111)) * 1440 -------- ---------------------- 4479.83333
We can use these functions to simply convert an overwhelmed time into minutes and write this value into the Oracle table. In this example, we have a logoff system-level trigger mechanism to calculate the session time that has started and put it in an Oracle StatsPack User_log extension form.
Update perfstat.stats $ user_logset ELAPSED_MINUTES = ROUND (to_number (logoff_time-logon_time) * 1440) Where user = user_idand elapsed_minutes is null;
Transfer from -ZDNet China