Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record Selection Formula not working

Status
Not open for further replies.

dev1212

Programmer
May 11, 2010
117
US
Hi

I have the following condition in my report, its somewhat similar to what
i posted few days ago for displaying the selected dates.

"If date was not specified, then use the prior billing cycle,
if there is no prior billing cycle then use the last calendar month dates
otherwise use the date provided by the user"

The formulas used in the record selection formula as follows,


{?Criteria}
========================
It is the parameter which gets populated in crystal reprots if there is any date selected from application.
The application calls the report and is created in such a way that it populates this parameter automatically
through some business objects applications.



{@Curr_Cyc_Beg_Dt_w_Ind}
=========================

If
{ACCT.CYC_IN}='1'
Then
{ACCT.CYCBEG_DT}


Logic for prior billing cycle
===============================

DateAdd("d",1,{ACCT.CYCEND_DT})={@Curr_Cyc_Beg_Dt_w_Ind}


{@LastMonthBeginDate}
=========================

DateAdd('m',-1,CurrentDate-Day(CurrentDate)+1)


{@LastMonthEndDate}
=========================

CurrentDate-Day(CurrentDate)




So i used following in selection formula

If
InStr({?Criteria},'/')=0
Then
{ACCT.PTG_DT} IN
(If
DateAdd("d",1,{ACCT.CYCEND_DT})={@Curr_Cyc_Beg_Dt_w_Ind}
Then
{ACCT.CYCBEG_DT} To {ACCT.CYCEND_DT}
Else
{@LastMonthBeginDate} To {@LastMonthEndDate}
)
Else
True



But i am not getting the required CYCBEG_DT and CYCEND_DT when there is prior billing cycle.


Please let me know the solution.

Please reply to this.


Thanks



 
Remove your filter and add a filter which brings back specific records which you know are prior billing cycle

Place in details

@Formula
DateAdd("d",1,{ACCT.CYCEND_DT})

{@Curr_Cyc_Beg_Dt_w_Ind}

and see if that gives you any clues.

Ian
 
The problem is that you are referencing a beginning date in your current cycle formula and then expecting it to look at the previous ending date in the dateadd() function--but the same row of data is being evaluated for each, so it is really looking at the end date for the current period. Try comparing the end date to the currentdate-day(currentdate) without the dateadd function:

(
If {ACCT.CYCEND_DT}= currentdate-day(currentdate) Then
{ACCT.CYCBEG_DT} To {ACCT.CYCEND_DT} else
{@LastMonthBeginDate} To {@LastMonthEndDate}
)

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top