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

Supressing current month's data for February in a leap year 1

Status
Not open for further replies.

jeffm777

IS-IT--Management
Nov 10, 2009
108
US
Hey guys. I need to supress the current month from a report so it only shows completed months on the report. I have this in my record selection but how do I compensate
for February on leap years?

local datevar endDate;
if month(currentdate) = 1 then
endDate := date(year(currentdate)-1,12,31)
else
if month(currentdate) = 2 then
endDate := date(year(currentdate),1,31)
else
if month(currentdate) = 3 then
endDate := date(year(currentdate),2,28)
else
if month(currentdate) = 4 then
endDate := date(year(currentdate),3,31)
else
if month(currentdate) = 5 then
endDate := date(year(currentdate),4,30)
else
if month(currentdate) = 6 then
endDate := date(year(currentdate),5,31)
else
if month(currentdate) = 7 then
endDate := date(year(currentdate),6,30)
else
if month(currentdate) = 8 then
endDate := date(year(currentdate),7,31)
else
if month(currentdate) = 9 then
endDate := date(year(currentdate),8,31)
else
if month(currentdate) = 10 then
endDate := date(year(currentdate),9,30)
else
if month(currentdate) = 11 then
endDate := date(year(currentdate),10,31)
else
if month(currentdate) = 12 then
endDate := date(year(currentdate),11,30);

{SalesClass.RecDate} >= Date (Year(currentdate)-3, 01, 01) and {SalesClass.RecDate} <= endDate

 
Change your formula to

endDate := dateadd("m", 1,date(year(currentdate), month(currentdate),01))-1

No need to test for each month.

Ian
 
It's not working...says the remaining text does not appear to be part of the formula. Here is my complete record selection...

local datevar endDate;

endDate := dateadd("m", 1,date(year(currentdate), month(currentdate),01))-1

{SalesClass.RecDate} >= Date (Year(currentdate)-3, 01, 01) and {SalesClass.RecDate} <= endDate and
{SalesClass.HomeYard} = {?Yard} and
{SalesClass.DeptNum} = {?Departments}
 
you need an 'AND' after Ian's formula & before your {SalesClass.......
 
Also you do not reall have to use a variable

{SalesClass.RecDate} >= Date (Year(currentdate)-3, 01, 01) and
{SalesClass.RecDate} <= dateadd("m", 1,date(year(currentdate), month(currentdate),01))-1
and
{SalesClass.HomeYard} = {?Yard} and
{SalesClass.DeptNum} = {?Departments}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top