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

Calculate no. of months between 2 dates

Status
Not open for further replies.

gavinlow

IS-IT--Management
Oct 14, 2002
12
SG
Very new to Crystal Reports and nobody in the company who are familiar with it. Is there an easy way to calculate the number of months between 2 dates? Basically, I need to select records whose transaction dates are of 1 month prior to current date (just the month difference will do).
 
Hey Gavin,

How does Date(Year(CurrentDate),Month(CurrentDate)-1,Day(CurrentDate)) grab you?

Naith
 
Datediff("m",Date1,Date2)

Now if Date 1 is 9/30/02 and date 2 is 10/1/02 -- only one day later -- this formula will still return a 1, the difference between the months.

If you read the help screens on Datediff() you will see several good examples of this.

Let me know if you have any questions. Software Training and Support for Macola, Crystal Reports and Goldmine
251-621-8972
dgilsdorf@mchsi.com
 
Does it handle across year? Say, current date is 15 JAN 2003. Will the formula give me 15 DEC 2002, 15 DEC 2003, or ERROR ?
 
Thanks everyone. I used to have problems with the HELP function (not installed properly). Now, it works. Saw the help on datediff. Very helpful. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top