on 2023 Feb 09 8:51 AM
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>
Request clarification before answering.
Hi,
Try this:
WHERE DAYS_BETWEEN (T0."U_DFrom", T0."U_DTo") < 30;
Hope this helps,
Son Tran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
66 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.