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

x number of weeks in future

Status
Not open for further replies.

RickBooker

Technical User
Jan 26, 2000
17
US
I have the following formula that computes data that is 7 weeks in the future:
if {JOB_START_DATE}-42 in WeekToDateFromSun
then {QTY_TO_MAKE}-{QTY_MANUFACTURED}
What I am trying to do is create a formula that will collect all data beyond 7 weeks. The number of weeks have to be from Sunday not current date.

Is there a way to compute the date of the first day of the week (sunday) that a date falls in? ie. if the date falls on thursday that is 8 weeks in the future can I compute the first day of that week?
Any point in the right direction would be appreciated.
Rick
 
To calculate the Sunday before any date you use the following:

{YourDateValue} - DayOfWeek({YourDateValue}) + 1 Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Thanks Ken. That's what I was after. I thought I could use the result of that to do what I wanted but I can't figure out how to do what I want.
Here's the formala that I came up with. It works fine but I was in hopes of finding a way to shorten it AND learn something along the way.
if not ({tblWIPMaster10.JOB_START_DATE} in (WeekToDateFromSun) and
not ({tblWIPMaster10.JOB_START_DATE}-7 in (WeekToDateFromSun)) and
not ({tblWIPMaster10.JOB_START_DATE}-14 in (WeekToDateFromSun)) and
not ({tblWIPMaster10.JOB_START_DATE}-21 in (WeekToDateFromSun)) and
not ({tblWIPMaster10.JOB_START_DATE}-28 in (WeekToDateFromSun)) and
not ({tblWIPMaster10.JOB_START_DATE}-35 in (WeekToDateFromSun)) and
not ({tblWIPMaster10.JOB_START_DATE}-42 in (WeekToDateFromSun)) )
then ({tblWIPMaster10.QTY_TO_MAKE}-{tblWIPMaster10.QTY_MANUFACTURED})

Like I said it works but I can see it becoming cumbersome if several more weeks were involved. Can you give a clue as to how I can shorten this?
Thanks in advance,
Rick
 
Now I am a bit lost. Assuming today is April 4th, 2001 (A Wednesday), exactly what dates are you looking to include in the report? Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
RickBooker: How about:

if {tblWIPMaster10.JOB_START_DATE}> ((currentdate - (Dayofweek(currentdate)+1))+ 42) then
{tblWIPMaster10.QTY_TO_MAKE}-{tblWIPMaster10.QTY_MANUFACTURED}


even better would be to create a parameter for the number of weeks out and then have the following:

if {tblWIPMaster10.JOB_START_DATE}> ((currentdate - (Dayofweek(currentdate)+1))+ (7*{?weeksout})) then
{tblWIPMaster10.QTY_TO_MAKE}-{tblWIPMaster10.QTY_MANUFACTURED}

Hope this helps
David C. Monks
david.monks@chase-international.com
Accredited Crystal Decisions Enterprise Partner
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top