计算dql documentum中两个日期之间的天数

to calculate number of days between two dates in dql documentum

我有两个属性,effect_date,next_effect_date。我必须以天为单位计算这两个日期之间的差异。 dql查询是什么?请帮忙

将此查询用于 dm_document 和日期属性 r_creation_dater_modify_date,它们是通用对象类型和属性:

select DATEDIFF(day, r_creation_date, r_modify_date)
from dm_document where r_object_id = '<set_id_here>'

当您指定对象类型名称时,我们可以调整此查询。 DATEDIFF 函数的语法是 DATEDIFF(date_part, date1, date2)

结果值取决于您存储库下的数据库。来自文档:

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'))