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!

How compare date and sysdate+n

bma66Dec 16 2017 — edited Dec 16 2017

hello,

i have a query that return two rows

DATE_ETEBARSYSDATE+30
01/15/201801/15/2018
01/15/201801/15/2018

the query is :

SELECT m.date_etebar, SYSDATE + 30

  FROM mh_vw_mo_ta_rep m, mh_tb_proje p, mh_tb_sarmayegozar s

WHERE m.code_rahgiri = p.code_rahgiri

       AND p.sarmayegozar_code = s.sarmayegozar_code

       AND ( mh_pkg.vaziate_koli_code( p.proje_code ) IN

                ( 'sakht', 'estelam' ) )

       AND ( m.pk_code = (SELECT MAX( s.pk_code )

                            FROM mh_vw_mo_ta_rep s

                           WHERE s.code_rahgiri = p.code_rahgiri) )

       AND TO_CHAR( tarikh_etebar, 'yyyy/mm/dd', 'nls_calendar=persian' ) =

               '1396/10/25';

but when i add condition

     m.tarikh_etebar=sysdate+30

then the result is 'no data found' ,

SELECT m.date_etebar, SYSDATE + 30

  FROM mh_vw_mo_ta_rep m, mh_tb_proje p, mh_tb_sarmayegozar s

WHERE m.code_rahgiri = p.code_rahgiri

       AND p.sarmayegozar_code = s.sarmayegozar_code

       AND ( ( m.date_etebar = (SYSDATE + 30) ) )

       AND ( mh_pkg.vaziate_koli_code( p.proje_code ) IN

                ( 'sakht', 'estelam' ) )

       AND ( m.pk_code = (SELECT MAX( s.pk_code )

                            FROM mh_vw_mo_ta_rep s

                           WHERE s.code_rahgiri = p.code_rahgiri) )

       AND TO_CHAR( tarikh_etebar, 'yyyy/mm/dd', 'nls_calendar=persian' ) =

               '1396/10/25'

mh_vw_mo_ta_rep  is view and date_etebar is date column. how compare date_etebar column with sysdate+30?

Regards

This post has been answered by Frank Kulash on Dec 16 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 13 2018
Added on Dec 16 2017
2 comments
5,232 views