Skip to Content
0

Difference between two date fields QUERY manager

Jul 26, 2017 at 09:24 PM

115

avatar image

I need to see the difference between two date fields for example:

SELECT T0."DocNum", T0."DocDate", T0."DocDueDate"

The difference between: (T0."DocDate " - T0."DocDueDate") = X days

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Nagarajan K Jul 26, 2017 at 10:53 PM
1

Hi,

Try this function,

Datediff(day, T0.docdate, T0.Docduedate) = X days.

Regards,

Nagarajan

Show 4 Share
10 |10000 characters needed characters left characters exceeded
It does not work, X days is the variable that gets the result, true? This I am doing from the query manager, I can not declare that variable. Should it work anyway?
0

Hi Christian,

The function is Datediff(day, T0.docdate, T0.Docduedate)

It will return an integer that is the difference in days between the given dates.

So you could use it like this:

SELECT T0.DocDate
     , T0.DocDueDate
     , Datediff(day, T0.docdate, T0.Docduedate) AS NumberOfDaysDifference
FROM ORDR T0

Regards,

Johan

0
Not working throws error: "invalid name of function or procedure: DATEDIFF
Why is it running in query manager?

 
0

Hi Christian,

Are you running on HANA ?

In that case you need to use the DAYS_BETWEEN function:

DAYS_BETWEEN (TO_DATE (T0.DocDate, 'YYYY-MM-DD'), TO_DATE(T0.DocDueDate, 'YYYY-MM-DD'))

Regards,

Johan

1
Nagarajan K Jul 28, 2017 at 10:34 PM
0

Run below function to get number of days in query generator

Datediff(day, T0.docdate, T0.Docduedate)

Share
10 |10000 characters needed characters left characters exceeded