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!

Week Ending Friday/Previous Friday 1

Status
Not open for further replies.

NewToCR

Programmer
Joined
Oct 20, 2005
Messages
54
Location
US
Hi everyone, I am looking for help.
I am creating CR 9.2 Report.

When Report opens it's date is Week Endind Friday. I am thinking previous Friday should be default unless it IS Friday today - then it is Current Friday.

What is the best way to go here? Procedure, SQL expression, formula?

I will have to have Previous Friday also for one column in this Report, just fyi.

Thanks for your time.
 
You could use a record selection formula like:

{table.date} <= dateserial(year(currentdate),month(currentdate), day(currentdate)-dayofweek(currentdate,crSaturday)+1)-1

For a column, substitute {table.date} for currentdate.

-LB
 
Magic...THANKS
I got it as a formula and it works as
dateserial(year(currentdate),month(currentdate), day(currentdate)-dayofweek(currentdate,crSaturday)+1)-1

For Last Week column if I am not using {table.date} - what do I do?

Thanks again
 
I don't know what you are trying to do in your report, so I am not sure I understand your question. If you have multiple weeks included in your report, then if you used your datefield instead of currentdate in the formula, it would show the last Friday for each of those dates. Is that what you would want a column to do?

-LB
 
My Report has:
________________________________________________________
Header
Week Ending: //Your Formula Here//

PRODUCTS Sold This week Sold Last Week
________________________________________________________

I am not sure how am I suppose to do this yet.
But all of it will probably be based on your formula above.

Thanks

 
If my formula is the end date of the report period, then you could use a record selection formula like:

{table.date} in dateserial(year(currentdate),month(currentdate), day(currentdate)-dayofweek(currentdate,crSaturday)+1)-15 to
dateserial(year(currentdate),month(currentdate), day(currentdate)-dayofweek(currentdate,crSaturday)+1)-1

Then your formula for {@thisweek} would be:

if {table.date} in dateserial(year(currentdate),month(currentdate), day(currentdate)-dayofweek(currentdate,crSaturday)+1)-8 to
dateserial(year(currentdate),month(currentdate), day(currentdate)-dayofweek(currentdate,crSaturday)+1)-1 then
{table.sales}

//{@lastweek} would look like:

if {table.date} in dateserial(year(currentdate),month(currentdate), day(currentdate)-dayofweek(currentdate,crSaturday)+1)-15 to
dateserial(year(currentdate),month(currentdate), day(currentdate)-dayofweek(currentdate,crSaturday)+1)-9 then
{table.sales}

-LB
 
Task was changed for me.
Now I will give them Parameter Range to choose a date ?Date
and I will have to calculate Prior Range which I want to set up as -7days from each entry.

Should I set 2 different dates instead of a Range and go
DateFrom -7 and DateTo-7? Or there is more sofisticated way?

Thanks
 
I think it would be easiest to have two parameters. Then your record selection formula would be:

{table.date} in {?datefrom}-7 to {?dateto}

Your current period formula would be:

if {table.date} in {?datefrom} to {?dateto} then {table.sales}

Your last week formula would be:

if {table.date} in {?datefrom}-7 to {?dateto}-7 then {table.sales}

-LB
 
I appreciate your help, I got somewhat smarter. Good weekend to you lbass.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top