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

Am trying to put in a formula the p

Status
Not open for further replies.

patty1

Programmer
Apr 17, 2002
105
US
Am trying to put in a formula the prior months date. In other words the user puts in the date parameters then in the report are the totals for that date parameter and the previous month's totals but I can't get the formula right to say what the previous month is.

Here is the formula for the month the user puts in:

totext({?StartDate},"MM/dd/yy") + " - " + totext({?EndDate},"MM/dd/yy")


I know I have to put -1 somewhere but have tried all ways but to no avail. Anyone...?
 
Try:

totext(dateadd("m",-1,{?start date}),"MM/dd/yy") + " - " + totext(dateadd("m",-1,{?end date}),"MM/dd/yy")

-k
 
Unfortunately am using Crystal 7.1 and dateadd does not work - any alternative? Tried doing:

totext(Date("m",-1,{?StartDate}),"MM/dd/yy") + " - " + totext(date("m",-1,{?EndDate}),"MM/dd/yy")

but I get message of need number here
 
Am now getting "a datetime is needed here" (cursor is after the -1,. The field is a datetime field but the "MM/dd/yy" just gave me the date which is what I need.

totext(dateadd("m",-1,{?StartDate}),"MM/dd/yy") + " - " + totext(dateadd("m",-1,{?EndDate}),"MM/dd/yy")

Thanks for the tip about the dateadd!
 
This means that your parameter field {?StartDate} is not a date or date/time datatype. Edit your parameter field and change the data type to date.


Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
Okay - the formula works but the parameter is showing the time as well as the date- my users only want to see the date. This is running off of a stored procedure - should I be doing some sort of conversion in there to go from datetime to date or can I do this in the formula?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top