Crystal Reports Training by Ken Hamady, MS, Reporting and Training Nationwide On Location TrainingPublic ClassesIndividual TrainingIntroductory Course OutlineAdvanced Course OutlineFormula ExamplesNewsletter Back IssuesMy BlogResource LibraryConsulting ServicesSupport ServicesContact InformationLinks to third party productsBack to main pageMy Credentials
Free Crystal Reports formula examples from KenHamady.com


To learn the techniques used in these formulas get:


The Expert's Guide to Crystal Reports Formulas
and
 Expert Techniques for Crystal Reports I, II & III

Finding the Monday of a selected week (weeks calculated via ISO Standard):

The following formula allows the user to pick a year and a week number, and have the formula calculate the Monday (or any other day) of that week.   In this example, the Year and Week are parameter fields.  The number at the end of the last line determines the day of the week that is returned as the final result.  Since this example ends with a 2, it will return a Monday.   Change it to 1 for Sunday or 7 for Saturday, etc.

WhileReadingRecords;
DateVar target := Date ({?Year},1,1);
    if DayOfWeek (
target) in 2 to 5
    then  
target:= target + 7 * ({?Week}-1) 
    else 
target:= target + 7 * ({?Week}) ;

target - DayOfWeek (target) + 2