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

Days in Month calculation

Status
Not open for further replies.

Lizhin

Programmer
Sep 19, 2001
1
US
In Crystal Reports 8, is there a function or formula that will calculate the number of days in a month if you give it the month, day and year as parameters? Thank you!!
 
The easy way is to work out the last day of the month.

numbervar m:= month({table.date}) + 1;
numbervar y:= year({table.date});
datevar lastday;

//Check it's not January in the following year
if m > 12 then (y := y + 1; m := 1);
//Last day of month is...
lastday := Date(y,m,1) -1;

//Days in month is equal to
day(lastday)
 

Day(DateSerial(Year(CurrentDateTime), Month(CurrentDateTime) + 1, 0))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top