cancel
Showing results for 
Search instead for 
Did you mean: 

Days Between function SAP HANA

former_member351438
Participant
0 Kudos
4,992

Hello Guys,

I'm trying to alert a query that will function if the U_DFrom table is less than 30 days to U_DTo table. Since Im new to Hana the usual Datediff will not work and im getting error using DAYS_BETWEEN function. Cannot find any example that the DATE_BETWEEN is in Where section.

Thanks for the help.

Here is my code.

SELECT T0."U_ComN", T0."U_ContN", T0."U_DFrom", T0."U_DTo", T0."U_Remarks" FROM "LIVEDB"."@ITDOCMAS" T0 WHERE DAYS_BETWEEN (TO_DATE (T0."U_DFrom", 'MM/DD/YYYY'), TO_DATE(T0."U_DTo", 'MM/DD/YYYY'))< '30'<br>

Accepted Solutions (0)

Answers (2)

Answers (2)

SonTran
Active Contributor
0 Kudos

Hi,

Try this:

WHERE DAYS_BETWEEN (T0."U_DFrom", T0."U_DTo") < 30;

Hope this helps,

Son Tran

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos

clay005

You don't need to use the DATE_BETWEEN function for this. Instead, use the DATEDIFF function.

SELECT 
  U_DFrom,
  U_DTo
FROM 
  Table
WHERE
  DATEDIFF('DAY', U_DFrom, U_DTo) < 30

The above query will return all rows where the difference between the two column values is less than 30 days.

michael_eaton3
Active Contributor
0 Kudos

A DATEDIFF function does not exist in any supported version of SAP HANA.

former_member351438
Participant
0 Kudos

This will not work in SAP Hana. I just wish SAP keep it that way.

wenxi_liu
Advisor
Advisor
0 Kudos

Me too. I hope that SAP hana can support DATEDIFF function.How do you calculate the date difference without DATEDIFF?