Home
Crystal Reports Training
Crystal Reports XI
Crystal Reports .NET
Crystal Reports Forum
News
Tech Support
Active Topics
Memberlist
Search
Help
Register
Login
Report Design
Crystal Reports Forum
:
Crystal Reports 9 through 2022
:
Report Design
Topic: Calculating months [RESOLVED]
Author
Message
cajsoft
Newbie
Joined: 23 Feb 2009
Location: United Kingdom
Online Status: Offline
Posts: 23
Topic: Calculating months [RESOLVED]
Posted: 05 May 2009 at 12:57am
Hi,
I require a formula in CRX to work out the no of complete months between to dates.
I dont want to use the datediff function as it doesnt evaulate the dates properly.
ie, stardate is 25/9/2008 enddate is 05/05/2009
datediff returns 20 which is incorrect.. it should be 19 complete months
hope someone can help
Craig.
Edited by cajsoft - 05 May 2009 at 2:37am
IP Logged
cajsoft
Newbie
Joined: 23 Feb 2009
Location: United Kingdom
Online Status: Offline
Posts: 23
Posted: 05 May 2009 at 2:37am
I found the answer myself:
WhilePrintingRecords;
//Years
//0.25 accounts for leap year
numbervar Y := (currentdate- {BIRTHDATE})/365.25;
//Months
//30.4375 = 365.25/12 average number of days in a month
numbervar M := Remainder((currentdate- {BIRTHDATE}),365.25)/30.4375;
// check for Months = 12
if truncate(M) = 12
then months := truncate(Y)+1
else months := (truncate(Y) * 12 + truncate(M) );
IP Logged
Printable version
Forum Jump
-- Select Forum --
Announcements
Talk with the Author
Self-Publishing
Job Postings
New feature request
Report Design
Data Connectivity
Technical Questions
Tips and Tricks
Crystal Xcelsius
Report Design
Data Connectivity
Writing Code
Tips and Tricks
Report Design
Data Connectivity
Writing Code
Tips and Tricks
You
cannot
post new topics in this forum
You
cannot
reply to topics in this forum
You
cannot
delete your posts in this forum
You
cannot
edit your posts in this forum
You
cannot
create polls in this forum
You
cannot
vote in polls in this forum
HOME
|
FREE EBOOK
|
PROGRAMMING GUIDE
|
PURCHASE
|
REVIEWS
|
CONTACT ME
|
FAQ
|
LINKS
|
PRIVACY
|
CLICK PLAYS
|
KONACAD
© 2004-2026 Brian Bischof. All Rights Reserved.