Syntax for calculating two time difference in DB2 and Oracle SQL statements

Source: Internet
Author: User
Tags db2

DB2 the syntax for calculating two date differences in a SQL statement

The end date is: 2015-10-10 11:30:00

Start Date: 2015-09-09 10:40:00

(1) Timestampdiff (8,char (end time-start time)) (overtime, seconds, zero) value of 744 hours

(2) (Days (end time)-days (start time)) *24 +hour (end time)-hour (start time) (No overtime seconds) value of 745 hours

(3) days (end date) The value of-days (start date) is 31 day

(4) Day (end date) The value of-day (start date) is 1 days

(5) Hour (end date)-hour (start date) value is 1 hours

(6) If the start date is 2012-09-09 10:00:00

Month (end date) The value of-month (start date) is 1 months

Syntax for calculating two date differences in an Oracle SQL statement

The end date is: 2015-5-27 11:20:47

Start Date: 2015-4-23 11:24:13

(1) Trunc (start time)-trunc (end time) value is 34 days (no overtime and seconds)

(2) Round (To_number (CAST (end date as date)-cast (start date as date)) has a value of 35 days (plus seconds/minute calculation to round)

(3) The value of round (To_number (CAST (end date as date)-cast (start date as date)) *24) is 816 hours (plus time and minute calculations are rounded)

(4) The value of round (To_number (CAST (end date as date)-cast (start date as date)) *24*60) is 48,957 minutes (plus time and minute calculations are rounded)

Syntax for calculating two time difference in DB2 and Oracle SQL statements

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.