Crystal reports2008 select the data range depending on runti

Hi,
I am new to crystal reports. I have a report that users want to run twice a month. When i run on 1st of this month i want to select lasfullmonth data and when i run on 15th i need to pick monthtodate data.
Any help!!!

Thank you in advance.


VJ29 (BOB member since 2011-06-20)

What is the database …?

You can write a stored procedure and in that check for the date… identify where it falls and develop a where criteria logic… Use that condition in your WHERE part in your query or
Write two different queries using IF THEN ELSE branching… only one query gets processed to return the result set.


BO_Chief :us: (BOB member since 2004-06-06)

Another report level solution could be using Date functions / formulae and ‘if then else’ logic in the report filters - selection criteria.
You can also change the filter logic from infoview dependig on the schedule dates.


shamanth (BOB member since 2007-03-01)

Thank you so much for your replies. I did that in Record selection with if then else.
It worked fine.


VJ29 (BOB member since 2011-06-20)

Hi,
I am sorry to come back again with the same question.
I have a criteria here.
My users want a report to run each week on Monday and Thursday with Month to date data.
Another request is they want it to run on 1st of the month with Last months’s data.
I am using sql server2005.
It’s not working properly when I do it in the record selection formula and they are telling that it’s not good to do it there. They want you to do it in the query itself(command area).
Any help???

Earlier I did like this and it didn’t workout good.
if day(CurrentDate) < 5 then {cmd.date} = LastFullMonth
else {cmd.date} = MonthToDate

Thank you in advance.


VJ29 (BOB member since 2011-06-20)

I think here what BO_CHief told will work out. I am not understanding where to start.
Another question is If 1st of the month haapens to be monday or Thursday how it’s going to work out.

THank you once again.


VJ29 (BOB member since 2011-06-20)

I got the solution and it worked fine.
Here it is

I created a prameter.
(’{?Period}’=‘Last Full Month’ and DT>=dateadd(mm,datediff(mm,0,getdate())-1,0)
AND DT<dateadd(mm,datediff(mm,0,getdate()),0)
or ‘{?Period}’=‘Month To Date’ and DT>=dateadd(mm,datediff(mm,0,getdate()),0))

Thanks to everybody who keeps on helping others in this forum. It’s really usefull.


VJ29 (BOB member since 2011-06-20)