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(urgent)

Former Member
0 Likes
1,280

hello experts

i want to subtract a date from a date suppose

ekko-bedat - mseg-bldat .how shall i do it

plz reply

hello experts

i want to subtract a date from a date suppose

ekko-bedat - mseg-bldat .how shall i do it

plz reply

11 REPLIES 11
Read only

Former Member
0 Likes
1,259

Hello,

You can do it directly.


data: lv_date like ekko-bedat.
lv_date = ekko-bedat - mseg-bldat.
write: lv_date.

Cheers,

Vasanth

Read only

0 Likes
1,259

hello i ahve done it from an internal table

data: d1 type ekko-bedat

d1 = it_ekpo-bedat - it_mseg-bldat.

but the output is comming as 00.00.0000

plz help

Read only

0 Likes
1,259

declare d1 as type i.

data : d1 type i.

d1 = it_ekpo-bedat - it_mseg-bldat.

Read only

0 Likes
1,259

Hello,

Does the two fields it_ekpo-bedat and it_mseg-bldat have values.

If it has the values then definetely the your d1 will give the result.

Cheers,

Vasanth

Read only

0 Likes
1,259

>

> hello i ahve done it from an internal table

> data: d1 type ekko-bedat


"here d1 supposed to store number of days.
"so declare d1 as type i NOT 'date' type.
DATA : d1 TYPE i.

> d1 = it_ekpo-bedat - it_mseg-bldat.

> but the output is comming as 00.00.0000

> plz help

Read only

Former Member
0 Likes
1,259

Hi,

u can subtract it directly.then it will give u the diff in number of days.

days = date1 - date2.

rgds,

bharat.

Read only

Former Member
0 Likes
1,259

Hi,

You can use the fucntion Module ' DAYS_BETWEEN_TWO_DATES'

Refer the link below :

Please reward points if useful.

Regards

rose

Read only

Former Member
0 Likes
1,259

Hi

Use the FM /SDF/CMO_DATETIME_DIFFERENCE where you can pass the 2 dates to date1 and date2 parameters to get the difference (in days).

Thanks

Vijay

Read only

Former Member
0 Likes
1,259

Use

DAYS_BETWEEN_TWO_DATES function module.

Award points if useful.

Read only

Former Member
0 Likes
1,259

Hi,

Check this code,

data: date type i.

date =ekko-bedat - mseg-bldat

write: / date.

Thats it. !!..

You can also have the date fields in two variables if you want to.

Reward if helpful.

Regards.

Read only

Former Member
0 Likes
1,259

hi try this ,

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,

venkat.