I have this query
select * from openQuery(hades,"select to_char(T$STDT,'dd-Mon-YYYY') stdt,to_char(T$TDAT,'dd-Mon-YYYY') tdat
,fdG2J(T$TDAT)-fdG2J(t$stdt) diff,T$DISC
,fdG2J(Sysdate) nSysD
,fdG2J(t$stdt) nStdt
,fdg2J(t$tdat) nTdat
from BAAN.TTDSLS031020
where T$CUNO='000022' and TRIM(T$CPGS)='1AA00'
--and fdG2J(sysdate) between fdG2J(t$stdt) and fdG2J(t$stdt)
");
and returns the following result (not that the last line of the where clause is commented out).
STDT TDAT DIFF T$DISC NSYSD NSTDT NTDAT
01-Mar-12 11-Mar-12 10010 40 2455990063 2455988061 2455998071
02-Mar-12 02-Mar-12 0 50 2455990063 2455989062 2455989062
06-Mar-12 11-Mar-12 5005 60 2455990063 2455993066 2455998071
11-Mar-12 11-Mar-12 0 70 2455990063 2455998071 2455998071
18-Jul-39 01-Jan-12 2907496166 80 2455990063 2465988199 5373484365
15-Dec-85 01-Jan-12 2817496016 80 2455990063 2555988349 5373484365
and whe I apply the commented between clause , the query returns no results (through sql2008 linked server)
and when I run the same query from Sql Developer (Oracle)
I get the first row
what is intriguing is:
a) why does this return different results when executed in different environments (although the server running the query is same server)?
b).why dos not between clause do not return expected result ?
I don’t know the indended functionality of
fdG2J(), but in theBETWEENclause, you use the same function call and argument value for both. Therefore, both return the same value andfdG2J(sysdate)would need to be exactly equal rather than between the range points.Perhaps you intended: