‎2007 Feb 06 9:03 AM
is there any function module to find the difference between two dates , i want the result to be displayed in days.
eg : days = 01.01.2006 - 01.01.2005
days : 365
Regards
Purshoth
‎2007 Feb 06 9:07 AM
hi,
data: dat1 type sy-datum.
data: dat2 type sy-datum.
data: days like P0347-SCRDD.
dat1 = '20051212'.
dat2 = '20061212'.
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
DATE1 = dat2
DATE2 = dat1
OUTPUT_FORMAT = '02'
IMPORTING
DAYS = days .
Write:/ days.Rgds
Anver
‎2007 Feb 06 9:10 AM
‎2007 Feb 06 9:11 AM
Hi,
you can simle calculate like this:
DATA: date like sy-datum.
data: days type i.
*
date = sy-datum - 100.
*
days = sy-datum - date.
*
write: date, sy-datum, days.
regards, Dieter
‎2007 Feb 06 9:15 AM
hI pURUSHOTTAM,
U can refer to following FMs to get the diffrence betwwn the dates as well as time in addition.
1. ' /SDF/CMO_DATETIME_DIFFERENCE ' - date and time both
2. ' SD_DATETIME_DIFFERENCE ' - date and time both
3. 'HR_HK_DIFF_BT_2_DATES'
If hope this helps u out.
regards
note: Reward ig useful
‎2007 Feb 06 9:17 AM
Hi Purru ,
U can have another approach to date difference. U can first convert the froamt then take the difference as follows
1. To convert Date Format using ABAP
data lv_date1 type sy-datum.
data lv_date2(12).
lv_date1 = '20070123'.
concatenate lv_date16(2) lv_date14(2) lv_date1+0(4) into lv_date2
separated by '.' .
is what you require to do;
now lv_date2 = 23.01.2007.
Also look for conversion routine "CONVERSION_EXIT_PDATE_OUTPUT"
EG: call function CONVERSION_EXIT_PDATE_OUTPUT
exporting input = lv_date1
importing output = lv_date2.
Also we can use function module CONVERT_DATE_TO_EXTERNAL .
I hope this helps u out.
Regards.
note: Reward if useful
‎2007 Feb 06 9:20 AM
if you want only the days between 2 dates then just subtract them
data : date1 like sy-datum value '20070206',
date2 like sy-datum value '20060206',
diff type i.
diff = date1 - date2.
write : / diff.
‎2007 Feb 06 9:25 AM
Hi,
Try this code.
data days type i.
data : d1 type sy-datum,
d2 type sy-datum.
if suppose c1 is having '01.01.2006' and c2 is having '01.01.2005,
concatenate c16(4) c10(2) c1+3(2) into d1.
concatenate c26(4) c20(2) c2+3(2) into d2.
Now d1 = '20060101'.
d2 = '20050101'.
days = d1 - d2.
write days.
‎2007 Feb 06 9:35 AM
Hi purshothaman,
1. days = 01.01.2006 - 01.01.2005
U already have the answer.
2. days = date1 - date2
will give the DIFFERENCE in days.
where days = i type variable
date1,date2 = sy-datum type variable
regards,
amit m.
‎2007 Feb 06 9:44 AM
<b>DAYS_BETWEEN_TWO_DATES </b>
MONTHS_BETWEEN_TWO_DATES Integer number
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
I_DATUM_BIS = x_faede-zfbdt
I_DATUM_VON = p_fdat
I_KZ_EXCL_VON = '0'
I_KZ_INCL_BIS = '0'
I_KZ_ULT_BIS = ' '
I_KZ_ULT_VON = ' '
I_STGMETH = '0'
I_SZBMETH = '1'
IMPORTING
E_TAGE = dias_v.
IF SY-SUBRC <> 0.
ENDIF.
donde:
x_faede-zfbdt -> 20050915
p_fdat -> 20050811
dias_v = 4
Message was edited by:
Judith Jessie Selvi