我有两个属性,effect_date,next_effect_date。我必须以天计算这两个日期之间的差异。什么是dql查询?请帮忙
答案 0 :(得分:2)
将此查询用于r_creation_date
和日期属性r_modify_date
和select DATEDIFF(day, r_creation_date, r_modify_date)
from dm_document where r_object_id = '<set_id_here>'
,它们是通用对象类型&amp;属性:
DATEDIFF(date_part, date1, date2)
指定对象类型名称时,我们可以调整此查询。
DATEDIFF函数的语法是If the repository is using Oracle or DB2, the return value is a floating point number.
If the repository is using DB2, the server assumes 365 days per year and 30.42 days per month (the
mean number of days in a month). These assumptions can cause return values that differ from the
expected value. To illustrate, the following example, which asks for the number of days between
March 1, 1996 and Feb 1, 1996, returns 30.42 instead of 28:
DATEDIFF(day, date('03/01/1996 0:0:0'),
date('02/01/1996 0:0:0'))
If the repository is using MS SQL Server, the return value is an integer for all units except day. If you
specify day in the function, the return value is a floating point.
The MS SQL Server implementation round up if the difference is one half or greater of the specified
unit. The implementations round down if the difference is less than one half of the specified unit. To
illustrate, the following example, which asks for the difference between March 1, 1996 and July 1,
1996 expressed as years, returns 0 because the difference is only 4 months.
DATEDIFF(year,date('03/01/1996'),date('07/01/1996'))
结果值取决于您的存储库下的DB。来自文档:
function myFunction(){
functionOne();
functionTwo();
}