Different Results from To Char in Query

68 views Asked by At

Here is a part of my code :

WHERE DSTOCK_YYMM BETWEEN TO_CHAR(:P_PERIODE1,'YY')||'00' AND TO_CHAR(:P_PERIODE1,'YY')||LTRIM(RTRIM(TO_CHAR((TO_CHAR(:P_P‌​ERIODE1,'MM')-1),'00‌​')))

where :P_PERIODE1 is 1 December 2016 so in other words :

WHERE DSTOCK_YYMM BETWEEN '1600'

What I want to ask is in Report Developer, those queries gave different result... The right result came from the hardcoded one ('1600'). Can anyone help we with this? Thanks in advance

Anne

1

There are 1 answers

0
VBoka On

This code gives me the same results... Maybe it will help you...

select TO_CHAR(sysdate,'YY')||'00' left_side, TO_CHAR(sysdate,'YY') || ltrim(to_char(to_number(TO_CHAR(sysdate,'MM')-1),'00')) right_side from dual;