开发者

Crystal report formula syntax

I have a report I am trying to modify in Crystal. It has a data field that has a formula in it, but I want to use another formula.

This is an example of what I am trying to do.

[((# Days in January) – 15) x (Market Rent/(# Days in January))]
 + [((# Days in February) – 0) x (Market Rent/(# Days in February))]
 + [14 x (Market Rent/(# Days in March))]

I have ADO commands built out for the market rent, and a start date and end date. The months in my example are just that an example. I am not sure how to take my ADO command dates that are entered in on a filter page, and put them in a formula like the one above. Any ideas?

Also, in the first and last para. the -15 and the 14 are for a date in开发者_如何学C the middle of the month. So if the start date was on the 15th of Jan, and the End date was the 15th of march. This formula would calculate my loss of rent during vacancy.


If I'm reading your question correctly, you want to take a date field and find out how to measure the number of days in that month, the month before it, and the month after it. Here's some Crystal formulas to help you out. Let's assume your date field is called {@DateFld}:

To find the number of days in a particular month relative to a particular date, try this:

local datevar X:=cdate(dateadd("m",0,{@DateFld}));

datediff(
   "d",
   date(year(X),month(X),1),
   date(year(X),month(X)+1,1)
)

I recommend you copy & paste this in 3 different formulas:
- In the 1st formula, replace the "0" with a -1 to get the number of days in the previous month.
- In the 2nd formula, don't change anything. That'll get you the number of days in the current month (i.e. the month that {@DateFld} is in)
- In the 3rd formula, replace the "0" with a +1 to get the number of days in the next month.

For example, if {@DateFld} is March 10th, 2011, the 1st formula will give you 28, the 2nd will give you 31, and the 3rd will give you 30.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜