SQL query:
SELECT
ROUND((CAST(DATEATTRIBUTE2 AS DATE) - CAST(DATEATTRIBUTE1 AS DATE)) * 86400) AS result
FROM TEST_TABLE;
Both DATEATTRIBUTE1 and DATEATTRIBUTE2 are of TIMESTAMP type.
I have tried and come up with the following XQuery :
fn:days-from-duration(fn:subtract-dateTimes-yielding-dayTimeDuration(
$P_REQUEST/ns1:DATEATTRIBUTE2,$P_REQUEST/ns1:DATEATTRIBUTE1))*86400
But this fails for cases when the dates are same but there is difference in time.E.g. When DATEATTRIBUTE1 is 2017-02-23T01:17:18.0000 and DATEATTRIBUTE2 is 2017-02-23T01:17:20.7550 the SQL query returns 2 while XQuery returns 0.
Thanks in advance for the help!