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

Issue on Dates

Former Member
0 Likes
844

Hi,

I want to subtract the two dates and get the no of days between them.

For ex: 20080314(YYYYMMDD) - 20031102

I want to get no of days between these two dates

Can anyone help on these

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
821

just subtract one date from other ...

data : v_date1 like sy-datum,

v_date2 like sy-datum.

data : v_diff type i.

v_diff = v_date2 - v_date1.

8 REPLIES 8
Read only

Former Member
0 Likes
821

Hi,

if the variables which are holding these variables are sy-datum or some other date types then u can do direct subtraction.

rgds,

bharat.

Read only

Former Member
0 Likes
822

just subtract one date from other ...

data : v_date1 like sy-datum,

v_date2 like sy-datum.

data : v_diff type i.

v_diff = v_date2 - v_date1.

Read only

0 Likes
821

Hi Srinivas,

Thanks a lot.........

Read only

Former Member
0 Likes
821

Hello,

Use this sample code:


data:  G_F_DIFF TYPE I
  CLEAR G_F_DIFF.
  CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
       EXPORTING
            I_DATUM_BIS             = G_T_PURO-AEDAT
            I_DATUM_VON             = G_T_EBAN-BADAT
       IMPORTING
            E_TAGE                  = G_F_DIFF
       EXCEPTIONS
            DAYS_METHOD_NOT_DEFINED = 1
            OTHERS                  = 2.
write: g_F_diff.

Cheers,

Vasanth

Read only

Former Member
0 Likes
821

Hi,

Use the FM : 'DAYS_BETWEEN_TWO_DATES'

data: G_F_DIFF TYPE I

CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'

EXPORTING

I_DATUM_BIS = G_T_PURO-AEDAT " Enddate

I_DATUM_VON = G_T_EBAN-BADAT " Start Date

IMPORTING

E_TAGE = G_F_DIFF

EXCEPTIONS

DAYS_METHOD_NOT_DEFINED = 1

OTHERS = 2.

write: g_F_diff.

Please reward points if useful.

Regards

Rose

Read only

Former Member
0 Likes
821

Hi,

Use FM DAYS_BETWEEN_TWO_DATES to get days

Read only

Former Member
0 Likes
821

hi,

you can add/subtract dates directly if the type is SY-DATUM.

Read only

Former Member
0 Likes
821

Hi,

Check this code,

data: date type i.

date = 20080314 - 20031102.

write: / date.

Thats it. !!..

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

Reward if helpful.

Regards.