Former Member

# How to calculate age of an equipment

Dear guys,

i need to calculate the age of an equipment, i have birth date of it and usuing info provider 0equipment for reporting.

How to subtract birth date from today? do i need to write a formula? i guess there is no sy-datum in bex.

Should i do it in the cube in update rule?

thanks

10|10000 characters needed characters exceeded

### Related questions

Former Member
Posted on Jun 19, 2008 at 07:25 AM

Hi John,

You can use any of these function module in routine to calculate the difference between two dates.

1. HR_HK_DIFF_BT_2_DATES

2. PARAMETER:p_date1 TYPE dats,

p_date2 TYPE dats.

DATA:lv_diff TYPE i.

CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'

EXPORTING

i_datum_bis = p_date1

i_datum_von = p_date2

IMPORTING

e_tage = lv_diff

EXCEPTIONS

days_method_not_defined = 1

OTHERS = 2.

IF sy-subrc = 0.

WRITE:/ lv_diff.

ENDIF.[/code]

3. DAYS_BETWEEN_TWO_DATES

4. HR_99S_INTERVAL_BETWEEN_DATES

5. sd_datetime_difference

Hope it helps you.

Regards,

Yokesh.

10|10000 characters needed characters exceeded
• Posted on Jun 19, 2008 at 07:44 AM

Hi John,

It is better to include a new field called age in the cube write a routine in update rules such that it should calculate SY-DATUM - Birth date.

If has to be calculate in BEx, I think you should have field consists of sy-datum, so that difference can be calculated using a formula variable SY-DATUM - Birth date..

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

Hope this helps..........

Rgs,

I.R.K

10|10000 characters needed characters exceeded
• Former Member
Posted on Jun 19, 2008 at 09:11 AM

Hi,

You have to calculate the age of the equipment at the query run time only. To calculate the age on any particular date (At the execution of query), you will need that (current) date. If you do it in the update rules, the age will be calculated at the time of loading the data.

In BEx you can use User Exit to calculate the age of the equipment dynamically.

Regards,

Yogesh.