In my SQL query I have,
TO_DATE('2019-07-22' , 'YYYY-MM-DD')
I want to pass sysdate-1
instead of hard coding the date value.
I tried this,
select TO_CHAR(to_date(
sysdate-1,'DD-Mon-YY'),'YYYY-MM-DD')dates from dual
and replaced the same in the SQL query but am getting the below error,
ORA-01861: literal does not match format string 01861. 00000 - "literal does not match format string" *Cause: Literals in the input must be the same length as literals in the format string (with the exception of leading whitespace). If the "FX" modifier has been toggled on, the literal must match exactly, with no extra whitespace. *Action: Correct the format string to match the literal.
sysdate - 1
. No need for anyto_date
,to_char
, or any format models. – mathguyto_date()
on a value that is already a date (whichsysdate
is). That will first convert thedate
value to avarchar
just to convert thatvarchar
back to adate
which it was to begin with. – a_horse_with_no_nametrunc(sysdate)
etc, rather than justsysdate
(unless the you want the time to be used as well) – Boneist