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

WeekToDateFromMonday 2

Status
Not open for further replies.

Nuffsaid

Technical User
Aug 3, 2001
374
CA
Hi All,

So tell me, someone has come up with either a formula or UFL that does this, right?

Like to here from ya......

Nuffsaid
 
First approach that comes to mind:

{DateField}
in Minimum( WeekToDateFromSun) + 1 to
Maximum( WeekToDateFromSun) + 1
Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Hi Again,

Ok so at first glance I thought Ken's formula would do the trick, but I've run into a problem.
Our weeks run Monday to Sunday and we sell 7 days a week.
At the close of business on Sunday I want to accumulate sales for the past week (WeekToDateFromMonday).

Ken, your formula works well Monday to Saturday, but on Sunday nothing shows up.
I believe that because it is “Sunday” the formula is evaluating week 2, not week 1.

Is this making any sense? Your comments would be appreciated.

Nuffsaid.
 
Sorry about that. I thought there would be a more elegant way, but I couldn't break the calendar week without an if statement. The following should work:

if DayOfWeek(currentDate) = 1
then
{Orders.Order Date} in
CurrentDate - Dayofweek(CurrentDate) - 5 to
CurrentDate - Dayofweek(CurrentDate) + 1

Else
{Orders.Order Date} in
CurrentDate - Dayofweek(CurrentDate)+ 2 to
CurrentDate - Dayofweek(CurrentDate) + 8
Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Thanks for your response Ken,

This is what I came up with, I created a formula @ThisWeek,
beforereadingrecords;
select DayOfWeek (CurrentDate)
case 1: CurrentDate-6
case 2: CurrentDate
case 3: CurrentDate-1
case 4: CurrentDate-2
case 5: CurrentDate-3
case 6: CurrentDate-4
case 7: CurrentDate-5

Then in the Select Expert,
{Datefield}>={@ThisWeek}

Seems Ok.....

Nuffsaid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top