Oracle Computing Time Difference Expression

Source: Internet
Author: User

-- Obtain the number of seconds of the difference between the two time periods
(Q. nh j ca0select Ceil (to_date ('2017-05-02 00:00:00 ', 'yyyy-mm-dd hh24-mi-ss')-to_date ('2017-04-30 23:59:59 ', 'yyyy-mm-dd hh24-mi-ss ') * 24*60*60*1000) differs from dual; 51testing Software Testing Network (e} & T-C ^
/*
Re5p2bv $ b5byd_0 difference grand seconds
. H B R) eiy0 ----------
(W (@ ejx5_0 86401000
K8 ^ 8lup '01 row selected
-Hq0l ^ d s7n0 */51testing software testing network Z '$ Q, B; h9o & X;/o

N7 [nm5zj | S0 -- returns the number of seconds for the difference between the two time ranges.
A &~ 5 [7C't * r-B0select Ceil (to_date ('2017-05-02 00:00:00 ', 'yyyy-mm-dd hh24-mi-ss ') -to_date ('1970-04-30 23:59:59 ', 'yyyy-mm-dd hh24-mi-ss') * 24*60*60) Time Difference from dual;
O6cj) m3c4c & D0/* 51testing software testing network 0j ;? : O8lea "K
Difference in seconds: 51testing software testing network JSR $ ~ O6g ^ 2E [
---------- 51testing software testing network 5li (jl1f1]
86401
% W ~ 7] r5i01 row selected51testing software testing network ux0 {2y kkgn, Q
*/
Z h1k # K; G; u]) eu051testing software testing network 5_n] 0b1wi
-- Obtain the time difference of 51 testing in minutes. Network: U af3a + xi1d + L
Select Ceil (to_date ('2017-05-02 00:00:00 ', 'yyyy-mm-dd hh24-mi-ss')-to_date ('2017-04-30 23:59:59 ', 'yyyy-mm-dd hh24-mi-ss ') * 24*60) number of minutes from dual;
: YPL-MP $ he ow0 /*
'^-@ % Aun/E. cu8h K0 difference in minutes 51testing software testing network azme' stwm3hy
----------
3nd % TB, h w + yl0 14.01testing software testing network kN! R1cy/N W
1 row selected51testing Software Testing Network C % E3A !? K: Uy
*/
"? $ _ Ed0e0
3_eh0i we & | 0 -- get the hours of difference between the two time periods
CT * y {+ f e @ x0select Ceil (to_date ('2017-05-02 00:00:00 ', 'yyyy-mm-dd hh24-mi-ss ') -to_date ('1970-04-30 23:59:59 ', 'yyyy-mm-dd hh24-mi-ss') * 24) hours of variation from dual; 51testing software testing network,} 8ff I? 7lf
/* 51testing Software Testing Network #/u/4r0 {XQ + c
Time Difference
RT % o6vu0 ----------
7 |/z5ik (/} 0 2551testing software testing network xo7l ''% P & D i6n
1 row selected
5e0o7 | vm0 */
Qi g w'bf {) eb051testing software testing network jto 'z Z/X. {6d
-- Get the difference between the two time periods: 51testing software testing network P "P (f2b my-ZC
Select Ceil (to_date ('2017-05-02 00:00:00 ', 'yyyy-mm-dd hh24-mi-ss')-to_date ('2017-04-30 23:59:59 ', 'yyyy-mm-dd hh24-mi-ss ') days from dual;
UA rfu6d0/* 51testing software testing network % t0u0wiwq u
Days difference
: Zdfgh; qk l0} y0 ----------
(E/3fb4xt O0 251testing software testing network rk, O, b2bt6g
1 row selected51testing software testing network % up JP _ + Y
*/
4wqq0q4d *? J # zd051testing software testing network WP6 ~ $ ^'S &?
-- Get the two-time month difference
/* {2D GTK, jv1ds0select (extract (year from to_date ('2017-05-01 ', 'yyyy-mm-dd ')) -extract (year from to_date ('1970-04-30 ', 'yyyy-mm-dd') * 12 + 51testing Software Testing Network & xko * k ^-UF # G. t
Extract (month from to_date ('2017-05-01 ', 'yyyy-mm-dd')-extract (month from to_date ('2017-04-30 ', 'yyyy-mm-dd') months51testing software testing network} X (e8rk
From dual;
9l1u [; P-nFF0/* months ---------- 131 row selected */
C "_ z: wvfg1fwt '051testing software testing network Q * SCSI (ZM
-- Get two time year difference
4d * u HQ Mt] 0 select extract (year from to_date ('2017-05-01 ', 'yyyy-mm-dd ')) -extract (year from to_date ('1970-04-30 ', 'yyyy-mm-dd') years from dual;
Qjv 'v &] 'k0 /*
Wj5nb N] 0years51testing Software Testing Network & b6n U. @ I
---------- 51testing software testing network 0' 3cxhr & E [
151testing software testing network 8 p} f; x + ^: O! Y1p
1 row selected51testing software testing network h: s5r9fa
*/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.