i'm using oracleDB for NodeJS, i dont know why query having the
LIKE '%/12'
not working on Date types and returns always empty array likewise it's still returning results for the same query inside Oracle client interface.
I tried escaping the '\', bypass binding thought it just interpreted it as params that should be passed.
In Oracle, a
DATEis a binary data-type consisting of 7 bytes representing century, year-of-century, month, day, hour, minute and second. It ALWAYS has those 7 components and it is NEVER stored in any particular human-readable format.When you use:
You are implicitly converting the date to a string so you are effectively doing:
If your
NLS_DATE_FORMATdoes not match (i.e. it has a-instead of/or the format isDD/MM/YYYYso that there is a 4-digit year at the end) then you will never match usingLIKE. Similarly, if your client application sets a specificNLS_DATE_FORMATfor your session but the NodeJS connection uses a different default for theNLS_DATE_FORMATthen you will get different behaviour when you rely on implicit conversions.Either explicitly convert your date to a string:
Or:
But using
LIKEseems pointless when you could just compare a single component of the date.Or use
EXTRACT:Or, if you are expecting
12to match a 2-digit year then: