Question:

Crystal Reports - Sequel - Date Range Question

by  |  earlier

0 LIKES UnLike

I’m trying to write a report and the date range of the data can’t exceed 30 days… from the first date selected. Which may not be todays date so

User selects Begin date of 12/01/07 and an End date of 2/2/08

The data retrieved should only be 12/01/07 – 12/31/07

Any clue how to write this in Sequel or Crystal Reports.

I can see a “30 days old” function … but that retrieves data 30 days old from current date.

 Tags:

   Report

2 ANSWERS


  1. You're halfway there, really. And you're better off filtering this data in your SQL Server rather than in Crystal Reports.

    In your SQL statement, you can use the BETWEEN function or a simple AND statement:

    SELECT * FROM MyTable WHERE ColumnDate >= BeginDate AND ColumnDate <= EndDate


  2. Create two parameters that collect single dates and name them ?BeginDate and ?EndDate.

    Create a formula called @AdjustedBeginDate that returns the ?BeginDate parameter.

    Create a formula called @AdjustedEndDate that returns the lesser of ?EndDate or ?BeginDate+30.

    In your record selection criteria, apply a filter on your database date field using the @AdjustedBeginDate and @AdjustedEndDate formulas.  For example,

    ({TABLENAME.DATEFIELDNAME} between {@AdjustedBeginDate} and {@AdjustedEndDate})

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions