I am using this code - where to_date(ops_review_date,‘YYYY-MM-DD’)>= TO_DATE(‘2023-12-01’,‘YYYY-MM-DD’) and
to_date(ops_review_date,‘YYYY-MM-DD’)<= CAST(TRUNC(SYSDATE) as date) -14
but getting error Invalid operation: invalid value for “YYYY” in source string"
I tried now() as well but same error
Hi @Neeraj1
can you share some sample data?
I guess the format for “ops_review_date” is different to “YYYY-MM-DD”.
What database are you using?
Not sure TRUNC() is expecting two arguments as well.
BR
Hi @ErikG ,
Date format is correct as shown in snapshot.
Requirement- Data should reflect current date -(minus)14 days so is there any other way to write the code?
Did you tried to perform the same query on the database?
Yes , i tried the query mentioned above and i tried this as well-
where ops_review_date between TO_DATE(‘2023-12-01’,‘YYYY-MM-DD’) and
(TO_DATE(‘{RUN_DATE_YYYY-MM-DD}’, ‘YYYY-MM-DD’) -14)
@Neeraj1
is the error in the first or second and-part?
Could you try to run both seperatly?
Maybe you can use dateadd() function instead of CAST(TRUNC(SYSDATE) as date) -14
like
dateadd(day,-14,SYSDATE)