Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

DATE CALCULATIONS

Former Member
0 Likes
790

I HAVE a key_date as select-option and i have wa3_zfbdt where wa_3 is a work area.

i want to subtract key_date - wa3_zfbdt and get the difference in the number od days how do i do it?

5 REPLIES 5
Read only

Former Member
0 Likes
728

Hi,

MODIFY THE PROGRAM FOR ACCORDING TO UR REQUIREMENTS.

REPORT ZDATEDIFF.

DATA: EDAYS LIKE VTBBEWE-ATAGE,

EMONTHS LIKE VTBBEWE-ATAGE,

EYEARS LIKE VTBBEWE-ATAGE.

PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,

TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.

call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'

exporting

i_date_from = FROMDATE

i_date_to = TODATE

I_FLG_SEPARATE = ' '

IMPORTING

E_DAYS = EDAYS

E_MONTHS = EMONTHS

E_YEARS = EYEARS.

WRITE:/ 'Difference in Days ', EDAYS.

WRITE:/ 'Difference in Months ', EMONTHS.

WRITE:/ 'Difference in Years ', EYEARS.

INITIALIZATION.

FROMDATE = SY-DATUM - 60.

Regards,

Read only

Former Member
0 Likes
728

Hi,

Please check the fm to claculate the difference.

1) DAYS_BETWEEN_TWO_DATES

Please pass paramters as follows when you run in se37 just pass 2 dates .

Import parameters Value

I_DATUM_BIS 02/20/2008

I_DATUM_VON 01/20/2008

I_KZ_EXCL_VON 0

I_KZ_INCL_BIS 0

I_KZ_ULT_BIS

I_KZ_ULT_VON

I_STGMETH 0

I_SZBMETH 1

Export parameters Value

E_TAGE 30

2) you can use this fm also to get the result:

Function module :FIMA_DAYS_BETWEEN_TWO_DATES

Import parameters Value

I_DATUM_VON 09/01/0001

I_KZ_EXCL_VON 0

I_KZ_ULT_VON

I_DATUM_BIS 10/01/0001

I_KZ_INCL_BIS 0

I_KZ_ULT_BIS

I_STGMETH 0

I_SZBMETH 1

I_SKALID

Export parameters Value

E_TAGE 30

Regds

Sivaparvathi

Please reward points if helpful...

Edited by: Siva Parvathi on Jan 10, 2008 9:04 AM

Read only

Former Member
0 Likes
728

Use FM

DAYS_BETWEEN_TWO_DATES..

Regards,

Mohaiyuddin

Read only

Former Member
0 Likes
728

Check the sample code for understanding for days calculation:


parameters: p_date1 type datum obligatory,
            p_date2 type datum obligatory.
data: days_diff type i.

start-of-selection.

   days_diff = p_date1 - p_date2.
   write:/ days_diff.

Alternatively you can use FM: DAYS_BETWEEN_TWO_DATES


    CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
      EXPORTING
        i_datum_bis                   = p_date1
        i_datum_von                   = p_date2
      IMPORTING
        E_TAGE                        = days_diff
     EXCEPTIONS
       DAYS_METHOD_NOT_DEFINED       = 1
       OTHERS                        = 2.

   write:/ days_diff.

Kind Regards

Eswar

Read only

Former Member
0 Likes
728

Hi,

Use the FM: 'HR_HK_DIFF_BT_2_DATES'.

PARAMETERS:

IMPORTING

*" VALUE(DATE1) (From Date)

*" VALUE(DATE2) (To Date)

*" VALUE(OUTPUT_FORMAT) (Pass '02' here)

*" EXPORTING

*" VALUE(YEARS)

*" VALUE(MONTHS)

*" VALUE(DAYS) ( Here u will get no. of days)

Rewards points if helpful.

Regards,

Srinivas Ch