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!

Issue In selecting date range and i am getting results out of my date selection in the querry..Pleas

2772999Nov 3 2014 — edited Nov 4 2014

Hi All,

I am getting an issue while generating the data between 2 dates. For from column i am giving a date of 10/2/2014 and for the to column im giving a date of 10/3/2014. The data should be between these two dates. In the final output 10/3/2013 is also getting included in the report. Could you please solve this issue. I am using the below piece of code for this extract in pl/sql

IF (to_date(p_Frm_Dt,'MM/DD/YYYY') IS NOT NULL OR TRIM(p_Frm_Dt) <> '') AND (to_date

(p_To_Dt,'MM/DD/YYYY') IS NOT NULL OR TRIM(p_To_Dt) <> '') THEN

                   if flagToWhere = '1' THEN

                         query_str:= query_str || ' WHERE CRTE_TS between ''' || to_date(p_Frm_Dt,'MM/DD/YYYY')  ||  ''' and ''' || to_date

(p_To_Dt,'MM/DD/YYYY')+1  ||  '''';

                   else

                         query_str:= query_str || ' WHERE CRTE_TS between ''' || to_date(p_Frm_Dt,'MM/DD/YYYY')  ||  ''' and ''' || to_date

(p_To_Dt,'MM/DD/YYYY')+1  ||  '''';

                      --query_str:= query_str || 'WHERE TO_CHAR(CRTE_TS,''MM/DD/YYYY'') between  ''01/07/2013'' and ''01/08/2013''';

                          --flagToWhere := '1';

                       END IF;

                END IF;

Below is the output i am getting for the above mentioned dates.

100000017310/03/201334381N6BF0LY2DN1064021668Y1000000173Y9359YYYYYYBOOKED
100000017410/03/201334381N6BF0LY5DN1025061668Y1000000174Y9360YYYYYYBOOKED
100000018410/03/201331533N6CM0KN8DK69342340044005Y1000000184Y9366YYYYYYBOOKED
100000018510/03/201320943N6CM0KN6DK69205817231724Y1000000185Y9369YYYYYYBOOKED
100000018610/03/201335501N6BF0LXXDN10698040094010Y1000000186Y9378YYYYYYBOOKED
100000012010/03/201335501N6BF0LXXDN10268540094010Y1000000120Y9379YYYYYYBOOKED
100000104710/02/201430511N6AF0KYXEN1072802125821259Y1000001047Y13600YYYYYYBOOKED
100000105410/02/201431211N4AZ0CP0FC30079720213Y1000001054Y13615YYYYYYBOOKED
100000105110/02/201433011N6BF0KX8EN10531421261Y1000001051Y13606YYYYYYBOOKED
100000105210/02/201433013N6CM0KN4EK70118021261Y1000001052Y13607YYYYYYBOOKED
100000105610/02/201430511N6BF0KX9EN10759021258Y1000001056Y13621YYYYYYBOOKED
100000105010/03/201413151N6BF0KY9EN1049082120121202Y1000001050Y13632YYYYYYBOOKED
100000105510/02/201433013N6CM0KN9EK70131921261Y1000001055Y13620YYYYYYBOOKED
100000104910/03/201418381N6BF0KL7EN10602912515Y1000001049Y13629YYYYYYBOOKED
100000105810/03/201427521N6BF0KY0EN1044902126521266Y1000001058Y13625YYYYYYBOOKED
12

Looking forward for your suggestions.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 2 2014
Added on Nov 3 2014
3 comments
983 views