Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

comparing date

francy77Aug 5 2020 — edited Aug 19 2020

Hi all,

i m not new at oracle sql but I have an issue i cannot understand, it is related with comparing data on sql.

I run this easy query:

select *

from telegram_result_vitt tr

where

tr.SENT_DATE_VI >  Last_Day(ADD_MONTHS(sysdate,-2))

and  tr.SENT_DATE_VI <  Last_Day(ADD_MONTHS(sysdate,-1))

and tr.tel_ref_id = 'WG73XXX6CD5001'

if the value inside the table telegram_result_vitt in the column SENT_DATE_VI  is set to 31-LUG-20 12:20:01,000000000

i can get the result, while if the value is set '31-LUG-20 13:20:01', the query dosn't give me any result;

but the condition are true in both case, because

in the case 31-LUG-20 12:20:01,000000000 i have

if tr.SENT_DATE_VI  >  Last_Day(ADD_MONTHS(sysdate,-2))    -----> YES

31-LUG-20 12:20:01,000000000  >  30-GIU-20

and

tr.SENT_DATE_VI <  Last_Day(ADD_MONTHS(sysdate,-1))

31-LUG-20 12:20:01,000000000  < 31-LUG-20------------------------------->YES

this is true too and tr.tel_ref_id = 'WG73XXX6CD5001'

and i get the result

in the case 31-LUG-20 13:20:01,,000000000

I can get any result but the condition are still true

if tr.SENT_DATE_VI  >  Last_Day(ADD_MONTHS(sysdate,-2))    -----> YES

31-LUG-20 13:20:01,,000000000 >  30-GIU-20                    

and

tr.SENT_DATE_VI <  Last_Day(ADD_MONTHS(sysdate,-1))

31-LUG-20 13:20:01,,000000000  < 31-LUG-20------------------------------->YES

thanks for help

Comments
Post Details
Added on Aug 5 2020
3 comments
193 views