Print Page | Close Window

Number of Days in a Month

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=4395
Printed Date: 27 May 2024 at 3:41pm


Topic: Number of Days in a Month
Posted By: coo7coo7
Subject: Number of Days in a Month
Date Posted: 29 Sep 2008 at 5:55am
HI guyz i need some help in crystal reports
 
i need a formula to find the number of days in a the month for a given date



Replies:
Posted By: rahulwalawalkar
Date Posted: 29 Sep 2008 at 7:14am
Hi
 
Create formula to get current month
 
mailto:%7b@Frm_Month - Frm_Month
Local numbervar m:= month(CurrentDate) + 1;
Local numbervar y:= year(CurrentDate);
If m>12 then
(m:=m-12; y:=y + 1);
Date(y,m,1)-1;
 
then create another formula to get No of Days
 
day( mailto:%7b@Frm_Month - {@Frm_Month })
 
the above formulas are from Chelsea Technologies Ltd - Crystal Clear
 
cheers
Rahul


Posted By: Savan
Date Posted: 30 Sep 2008 at 5:12am
you can do this way also create a forumula noofdays as following :
 
if (month(today) in [1,3,5,7,8,10,12]) then
     31
else if (month(today) in [4,6,9,11]) then
    30
else if (month(today) = 2 and remainder(year(today),2) = 0) then
    29
else
    28;
 
replace today with  table field name (date field)


-------------
Thanks
Savan



Print Page | Close Window