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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Previous Weekday

Status
Not open for further replies.

M8KWR

Programmer
Aug 18, 2004
864
GB
I am using a 3rd party application called Crystal Report Distributor (CRD).

I have a parameter that asks the user to input the date they want to query the report on. CRD uses this and I can tell it what print, and then email on to certain address.

What i have at the moment is this

{CONTHIST.ONDATE} = currentdate-1

I have told crystal to print yesterdays date.

But the issue i have is that if i'm sending report on a Monday I need to Fridays date, and not Sundays. Does anybody know how to do this.

I can not send them on a Saturday, they have to go on a Monday...

Many thanks for anu help in advance...
 
Change you record selection to this:

{CONTHIST.ONDATE} =
switch
(
dayofweek(currentdate)=1,currentdate-2,
dayofweek(currentdate)=2,currentdate-3,
true,currentdate-1
)



~Brian
 
I update it, and now it says "Login Failed"

I do have options in CRD to set DB Login - but this is optional, and it did work before when nothing was filled in...

Thanks for your help so far...
 
if its any help to anyones

I used

{CONTHIST.ONDATE} =

IIF (dayofweek(currentdate) = 2, currentdate-3, currentdate-1)

And it work fine...
 
I don't understand why you'd use that if you have a parameter?

If you are prompting the user, a common scenario is to set a default, and then if they don't enter an overriding date, it will use the last weekday.

The code ould be something like:

Set a default value for the date of 1/1/1970, and in the description place "select this for the default"

Then in the Record Selection Formula->Record:

if {?MyDateParm} <> cdate(1970,1,1) then
{CONTHIST.ONDATE} = {?MyDateParm}
else
if {?MyDateParm} = cdate(1970,1,1) then
{CONTHIST.ONDATE} = IIF (dayofweek(currentdate) = 2, currentdate-3, currentdate-1)

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top