cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between two date fields QUERY manager

0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

kothandaraman_nagarajan
Active Contributor

Hi,

Try this function,

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

Regards,

Nagarajan

0 Kudos
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?
Johan_H
Active Contributor
0 Kudos

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 Kudos
Not working throws error: "invalid name of function or procedure: DATEDIFF
Why is it running in query manager?

 
Johan_H
Active Contributor

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

Answers (1)

Answers (1)

kothandaraman_nagarajan
Active Contributor
0 Kudos

Run below function to get number of days in query generator

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