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!

LastFullMonth function

Status
Not open for further replies.

lana123

Programmer
Aug 20, 2003
79
US
Hi,people
I have to show in my report(Crystal 9.2)only the records that were created in the last day of the previous month.
I'm using for my parameter
{?OpenDate}=maximum(LastFullMonth) formula
but it doesn't show up in the Database "Show SQL Query" window.
I'll appreciate any suggestions.

Thanks,

Lana
 
Hi Lana,

Why are you using a parameter if you're going to hard code a value to it in the record selection criteria? The purpose of a parameter is to allow choice. Also, this code assigns a value to the parameter, but it doesn't actually affect record selection criteria. Generally, a parameter would be used as follows:
Code:
{table.datefield} = {?DateParameter}
. This allows the user to assign a value to {?DateParameter}, which will then be passed to the database as a filter for the {table.datefield} field.

Is this snippet of code part of a larger statement? If so, would you please post your entire record selection statement? This will help us to better identify and address your issue.


~Kurt
 
As Kurt says, if you want to allow the user to pick the day to run the report, use his sample above.

If you want the report to always run on the last day of th previous month, then modify your selection criteria to this:
Code:
{table.datefield} = maximum(lastfullmonth)

If you wanted the flexibility of allowing for them to select a particular day, or the last day of the previous month, you could do that as well.
Create a default value for the date parameter, which is well out of the normal date range. Perhaps something like 1/1/1900.
In your selection criteria, add the following lines instead of what you used above:
Code:
(
if {?Date_Parm} = CDate(1900,1,1) then
    {table.datefield} = maximum(lastfullmonth)
else if {?Date_Parm} <> CDate(1900,1,1) then
    {table.datefield} = {?Date_Parm} 
)
If the user chooses 1/1/1900 in the parameter, the selection will be based upon the last day of the previous, otherwise it will use the date provided in the parameter.

~Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top