Application Development 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: 

date validation

0 Kudos
83

Hi everyone,

Do the needful,

Im passing two dates, where i have to get no of years, months and days.

Ex 1. If i pass from date : 10.10.2005

to date : 09.09.2007

my output should be as

No of Days : 30

No of Months : 11

No of Years : 01

Ex 2. If i pass from date : 10.10.2005

to date : 10.10.2007

my output should be as

No of Days : 00

No of Months : 00

No of Years : 02

Its vry urgent,

Point will be rewarder for ur efforts,

thanks in advance

Stanley

5 REPLIES 5

Former Member
0 Kudos
47

Hi Stanley,

Try out this code,

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.

Hope this helps u.

Former Member
0 Kudos
47

Subtract the 2 dates .

Divide by 365 to get the year

use remainder divide by 30 to get months

rest are days

Former Member
0 Kudos
47

Hi

declare the variables

data: v_mon type i, v_yr type I, v_days type i, v_days1 type I,v_days2 type I,

date1 like sy-datum, date2 like sy-datum.

two dates are given

Date1 = '20051010'.

and Date2 = '20070909'.

v_days = date2 - date1.

v_yr = v_days / 365 . this gives the number of years.

v_days1 = v_days - ( v_yr * 365 ).

v_mon = v_days1 / 30. ...this gives the no of months.

v_days2 = v_days1 - ( v_mon * 30 ). .. this gives the days

answer is years = v_yr.

months = v_mon.

days = v-days2.

do this and see

<b>Reward points for useful Answers</b>

Regards

Anji

.

Former Member
0 Kudos
47

Hi...,

Use this Fm RH_PM_CONVERT_DATE_TO_MONTH to get the difference between two dates in terms of months....

Use this Fm RH_PM_CONVERT_DATE_TO_YEAR to get the difference between two dates in terms of YEARS....

Former Member
0 Kudos
47

<b>Find the difference between two days in days, months and years

*

  • Type in two date and find the difference between the two dates in

  • days, months and years.</b>

*

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:/ 'No of Days  : ', EDAYS.
WRITE:/ 'No of Months: ', EMONTHS.
WRITE:/ 'No of Years:  ', EYEARS.

reward points if it is usefull....

Girish