cancel
Showing results for 
Search instead for 
Did you mean: 

Calculate no days from two dates

Former Member
0 Kudos

Hi,

i want to create a calculated keyfigure to display no of days from two keyfigures ( A & B).

I am using the formula as CKF = b-a ( No of days)

If the value of a keyfigure is zero then system is displaying some odd number. Is there any better way to calculate difference between two numbers.

Regards,

Reddy.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Say you have two date ranges From_date and To_date. now if both the values are noo zero then the formula (To_date - From_date) would work fine..but if one of the values is zero then you will have to decide upon some value to build the formula.

1. if To_dtae = 0

you can take the system date in that case. or the report execution date as To-date and build the formula using some boolean operatos.

2. if From_date = 0

here you need to decide the start date as some value of your interest say 01.01.2008 or depending on the transactions of the business data some value.(if you dont have the range value you cannot calculate the days).Apply the boolean operators and calculate the value for days.

Bhavna.

Answers (1)

Answers (1)

Former Member
0 Kudos

Dates are calculated as no of days from a particular date (for SAP it is 01/01/1000 I think).

If one of the dates in calculation comes as zero, the result is going to be a large no (see above).

You may want to put a boolean multiplier to your formula to take care of situations where one date is zero. (What really do you want to see in say '20090812 minus zero'? You need to decide that and formulate accordingly.)

Former Member
0 Kudos

Hi Ajay,

Thanks for reply, Please can you sugest some example boolean operators.

Regards,

Reddy.

shanthi_bhaskar
Active Contributor
0 Kudos

reddy,

How to use Replacement Path Variables to perform Date Calculations A Step-by-Step guide

http://www.sd-solutions.com/documents/SDS_BW_Replacement%20Path%20Variables.html

Former Member
0 Kudos

Hi Shanti,

My dates are keyfigures not characteristics.

Regards,

Reddy.

former_member181964
Active Contributor
0 Kudos

Hi,

Use the following FM and calculate it. In your case you are telling that the dates are keyFigures, so ask ABAPer how to convert it to 0CALDAY formate then use the following FM. Better you load that Keyfigures data to Two ZDATE1 and ZDATE2 Time charecteristics and do the calculation.

/SDF/CMO_DATETIME_DIFFERENCE

Thanks

Reddy