Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Modifying code to return Current month data. Post Reply Post New Topic
Author Message
Nav522
Senior Member
Senior Member


Joined: 25 Aug 2009
Location: United States
Online Status: Offline
Posts: 166
Quote Nav522 Replybullet Topic: Modifying code to return Current month data.
     Posted: 30 Sep 2009 at 2:22pm
 
Hello Folks i have this urgent requirement where i need to modify this code so that it has to return data from the Current month First Day to the previous Day if its a daily report and previous month data if its a monthly report.
I have no clue how to modify this code below. Currently the code is returning data for Monthly reports for the previous month. Does anyone have any idea how to modify so that the code meets the requirements of both daily and monthly reprts.
 
 
 
BEGIN

  if v_lowdate is null or v_highdate is null then
    select to_number(to_char(sysdate,
'DD')) into v_cur_day from dual;
    if v_cur_day <
25 then
     
-- this is for the previous month run
      Select Add_Months(trunc(sysdate,
'MONTH'), -1)
      INTO   V_LOWDATE
      FROM   DUAL;
   
      SELECT Last_Day(ADD_Months(Sysdate, -
1)) INTO V_Highdate From Dual;
    else
     
-- this is for the current month run
      Select trunc(sysdate,
'MONTH') INTO V_LOWDATE FROM DUAL;
   
      SELECT Last_Day(Sysdate) INTO V_Highdate From Dual;
    end if;
 
  end if;
 
 
 
 
Thanks
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

  


Edited by Nav522 - 30 Sep 2009 at 2:22pm
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum