Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Months calculation Post Reply Post New Topic
Author Message
arunareddya
Newbie
Newbie


Joined: 28 Oct 2010
Location: India
Online Status: Offline
Posts: 1
Quote arunareddya Replybullet Topic: Months calculation
     Posted: 28 Oct 2010 at 12:45am
HI,
 
Could anybody suggest how to calculate months between two dates. I have requirement to calculate months between currentdate to the other date.
 
I am using datediff function :
 
Suppose my databse column has date value 1-Jan-10 then I need the months between current date to the 1-Jan-10 .
 
When I use datediff it is giving value as 9.But the actuals  9+ So i need to display 10.
 
I am new to crystal reports. Could anybody suggest how to progress on this?
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 28 Oct 2010 at 3:29am
I am guessing that you are using the month function of DATEDIFF.  It will calculate by just looking at the date, 10/24/10 - 1/1/10...10-1=9. 
 
The solution is use the day function, and then divide by some value (average days in a month) to get the months (approximate) or use DAY() to the the day values and subtract them and then use some cutoff value to determine if you need to 'round up' to the next month (also approximate, but probably closer to what you are looking for)
 
HTH
IP IP Logged
Printable version Printable version

Forum Jump
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