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

[b]-4714 Part of Date Range when no Lower Bound Box ticked [/b]

Status
Not open for further replies.

Nassy

Programmer
Mar 27, 2003
121
GB
Hi everyone,

I have created a simple report which includes a parameter as a date range. At the top of the report I display the parameter values the user selected once the report is refreshed.

What the problem is

When entering a date range, if the user selects a date range with no lower bound (ie no start date) then when the report is refreshed Crystal will correctly identify today's date as the end of the date range but displays the following date as the start date:

31 December -4714

So the date range would come up on the screen something like

Date Range: 31 December -4714 to 04 Feb 2005

While the users of my report will probably understand that this date of 31 December -4717 represents 'no start date' I am wondering why Crystal is putting that there in the first place ie why doesn't Crystal just display nothing if there is no start date. If anyone could tell me if this is a known Crystal bug/ limitation or not would be great and whether there is any workaround or may be a patch I can apply to sort out this issue. I know it is not affecting the functionality on my report but the reports I create are seen by many people in the business and this use of what looks like a random code on the report does not create a professional image!

Any help would be very much appreciated as I have searched the web for info on this problem and find nothing. [ponder]

Nassy
 
If you're using CR 9 or ( CR10 with CE) , there is a function in the repository to do this.
See below

If you're using 8.5 , you could adapt the code from the function.

Code:
//cdFormatDateRange

Function (DateVar range rng)
    
    DateVar minValue := Minimum (rng);
    DateVar maxValue := Maximum (rng);

    StringVar minString := CStr (minValue);
    StringVar maxString := CStr (maxValue);
   
    if HasLowerBound (rng) and HasUpperBound (rng) then
    (
        // To, _To, To_ or _To_

        if IncludesLowerBound (rng) and IncludesUpperBound (rng) then
        (
            if minValue = maxValue then
                minString
            else
                "between " + minString + " and " + maxString
        )
        else if IncludesLowerBound (rng) then
            "between " + minString + " and " + maxString + " not including right endpoint"
        else if IncludesUpperBound (rng) then   
            "between " + minString + " and " + maxString + " not including left endpoint"
        else
            "between " + minString + " and " + maxString + " not including endpoints"
    )
    else if HasLowerBound (rng) then
    (
        // Is > or Is >=

        if IncludesLowerBound (rng) then
            "greater than or equal to " + minString
        else
            "greater than " + minString
    )
    else if HasUpperBound (rng) then
    (
        // Is < or Is <=

        if IncludesUpperBound (rng) then
            "less than or equal to " + maxString
        else
            "less than " + maxString
    )

HTH


Bob Suruncle
 
In 8.0 I can't recreate the issue. I can use a formula like:

(If minimum({?daterange}) = date(0,0,0) then
"Dates Through " else
totext(minimum({?daterange})) + " to ") +
totext(maximum({?daterange}))

Since your default doesn't look like date(0,0,0), I wonder if you could use a formula like:

(if year(minimum({?daterange})) < 0 then
"Dates Through " else
totext(minimum({?daterange})) + " to ") +
totext(maximum({?daterange}))

-LB
 
Thanks for all the replies. I shall try out these solutions.

Nassy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top