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

Monthly Report

Status
Not open for further replies.

rb2005

Programmer
Mar 7, 2005
110
US
I was using a formula called period to get last month summary data.

MonthName(Month (currentdate)-1). It was working fine last year. But this is failing in Jan. I know why it is failing. But is there any alternative??? Basically I want to see last month data and want to display the last month name in the report.

Thanks for your help in advance.
 
I'm surprised it failed, but try
Code:
MonthName(DateAdd("m", -1, currentdate)

If this fails, try
Code:
ToText(DateAdd("m", -1, currentdate), "MMM")
-or MMMM for the full month name.

It helps to give your Crystal version. And to say what you get when something fails.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Thanks a lot.
I forgot I have used other formula. I thought I can share with you...

if Month (DataDate) = 1 then MonthName(12)
else MonthName(Month (DataDate)-1)

I am having problem with Annual Report Also.I was using
Year (currentdate)-1 to see last year's data. The report is running without data. Which is wrong. Any clue?
 
You're not comparing this to a field, so it makes sense that it does nothing.

You should alos post your software version with any post about any software as the solutions vary.

To get last years data you might go to Report->Seleciton Formula-Record and use:

(
{table.date} >= dateserial(year(currentdate)-1,1,1)
and
{table.date} <= dateserial(year(currentdate),1,1)-1
)

With later versions of Crystal the SQL pass through is more generous, this is designed to allow for older versions as well.

Anyway, keep the dateserial function in mind.

-k
 
Thanks. I had this thing in report selection area

{table.field} in LastYearYTD

Thanks a lot for your help.
 
That's not last year, that's last year only up to the same date as the current date.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top