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

Adding / Subtracting months in Crystal Reports

Status
Not open for further replies.

srikrish

Programmer
May 8, 2000
3
US
Hi,

Is it possible to add a database numeric field (considering it as months) to another database field which is of date datatype. For example, I would like to add a field 'Review Date' (date data type having a value of 01-JAN-2001) and 'Next Review In' field which is of numeric datatype having a value of 6. Now, I want to add these two fields and arrive at the output of 01-JUL-2001). Please let me know if you could get me any sort of solution for this.

Thanks,
Srini
 
srikrish: You can merely add a numeric value to a date but the result will be that number of days into the future. You don't mention which version of CR you are using but if it is v8 then you can use the DateAdd() function which enables you to define an interval ("m"), how many of these you want (6) and the original date field (ReviewDate) to produce e.g. DateAdd("m",6,{ReviewDate}) - this will give you Netx Review. Alternatively if you are using an earlier version then your formula will need to be a bit more complex:

If Month(ReviewDate)+6 >12 then
Date(Year(ReviewDate)+1,Month(ReviewDate)-6,Day(ReviewDate)
else
Date(Year(ReviewDate),Month(ReviewDate)+6,Day(ReviewDate) David C. Monks
david.monks@chase-international.com
Accredited Seagate Enterprise Partner
 
srikrish: Sorry Srini there was a typo in my last post - formula should read as follows:

If Month(ReviewDate)+6 >12 then
Date(Year(ReviewDate)+1,Month(ReviewDate)-6,Day(ReviewDate))
else
Date(Year(ReviewDate),Month(ReviewDate)+6,Day(ReviewDate))


David C. Monks
david.monks@chase-international.com
Accredited Seagate Enterprise Partner
 
Hi David,

I appreciate your immediate response in this regard. However, we were able to apply the patch u25dateadd.dll which was supplied by Segate Crystal Reports and were able to use the DateAdd function directly. Thanks for your immediate reply and now through with the issue.

Thanks,
Srini
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top