How to calculate the number of days in the two-day period in SQL/400

Source: Internet
Author: User
In SQL 400, how does one calculate the number of days in a two-day period?
Solution 1: Use the date function to return an 8-digit number in the format of 'yyyymmdd:
Select digits (date ('2014/1/01')-date ('2014/3/99') from ....
Return Value: '20140901', indicating that the number of days is 1 year, 8 months, and 28 days;

2. Use the days function to return a 10-digit number:
Select digits (days ('2017/96 ')-days ('2017/95') from ....
Return Value: '20140901', indicating that the number of days is 0000000365 days;

Note: The date and days parameters of the function can be field names, so this method can also be used to calculate records
The number of days between a field and a specific date:
Select digits (days (field1)-days ('2017/95') from ....

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.