‎2008 Jul 30 7:48 AM
Can we Subtract Date for Ex. 21/07/2008 - 10/07/2008. ?
how can we solve this date ? please give me the code?
‎2008 Jul 30 7:49 AM
Hi,
Yes you can Subtract date or Add Date.
You can also use FM.
Check this link
http://sap-abapinfo.blogspot.com/2008/03/sap-function-module-for-date-and-time.html
Regards,
Sujit
‎2008 Jul 30 7:51 AM
you can always subtract or add a date to another , we use FM's to do this
try this FM's:
RP_CALC_DATE_IN_INTERVAL
Add/subtract years/months/days from a date
SD_DATETIME_DIFFERENCE
Give the difference in Days and Time for 2 dates
With luck,
Pritam.
‎2008 Jul 30 7:52 AM
hi
use this FM
MONTHS_BETWEEN_TWO_DATES : To get the number of months between the two dates.
END_OF_MONTH_DETERMINE_2 : Determines the End of a Month.
HR_HK_DIFF_BT_2_DATES : Find the difference between two dates in years, months and days.
FIMA_DAYS_AND_MONTHS_AND_YEARS : Find the difference between two dates in years, months and days.
Cheers
Snehi
‎2008 Jul 30 7:52 AM
Hi,
check this.
HR_HK_DIFF_BT_2_DATES : Find the difference between two dates in years, months and days.
FIMA_DAYS_AND_MONTHS_AND_YEARS : Find the difference between two dates in years, months and days.
SD_CALC_DURATION_FROM_DATETIME : Find the difference between two date/time and report the difference in hours
L_MC_TIME_DIFFERENCE : Find the time difference between two date/time
HR_99S_INTERVAL_BETWEEN_DATES : Difference between two dates in days, weeks, months
u can get all FM regarding dates in this thread
‎2008 Jul 30 7:52 AM
Hi Bala,
Declare the date variables of type sy-datum and then directly subtract those two dates.
You will get the difference in no. of days
Regards,
Chandra Sekhar
‎2008 Jul 30 7:53 AM
Hi bala,
Use the FM:-
*FIMA_DAYS_AND_MONTHS_AND_YEARS *
This will resolve your issue.
Best of luck,
Bhumika
‎2008 Jul 30 7:54 AM
hi,
U can do like that, if u want more just try this.
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.Regards,
Anversha
‎2008 Jul 30 7:54 AM
Hi,
Please try using FM DAYS_BETWEEN_TWO_DATES.
Thanks,
Sriram POnna.
‎2008 Jul 30 7:56 AM
‎2008 Jul 30 7:58 AM
Hi,
U can use the below code for the date calculation... i hope will give to some help....
.
data: C_date like sy-datum,
P_date like sy-datum,
B_DATE TYPE DATUM,
E_DATE TYPE DATUM.
C_date = sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = C_date
days = 00 "--> no of days date to be substracted
months = 1
SIGNUM = '-'
years = 00
IMPORTING
CALC_DATE = P_date.
write:/'Current date', C_date,
'Old date ', P_date.
CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
EXPORTING
iv_date = P_DATE
IMPORTING
EV_MONTH_BEGIN_DATE = B_DATE
EV_MONTH_END_DATE = E_DATE.
write:/'Begin date', B_date,
'End date ', E_date.
you can use any of the above two functions to calculate the difference of two dates...
Thanks & Regards
Ashu Singh.
.
‎2008 Jul 30 8:09 AM
Hi Bala.
I would like to suggest a few references,
[SDN - Reference for Calculating Difference between two dates in days|;
[SDN - Reference for Difference between dates|;
[SDN - Reference for Difference between two dates required in years and months|;
[SDN - Reference for calculate the number of days between dates : Date difference Calculation|;
[SDN SAP Note - 1213507 - Subtracting one date field from another to get the difference in days|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do]
[SDN - Reference for Function Module for difference between two dates|;
Hope that's usefull.
Good Luck & Regards.
Harsh Dave
‎2008 Jul 30 8:09 AM
Hi
Try this...
DATA: date1 type d value '20080721',
date2 type d value '20080710',
date3 type d.
date3 = date1 -date2.
write:/ date3.
Hope it helps.
Murthy
‎2008 Jul 30 8:50 AM
Hi Bala,
When you subtract two dates as you are doing in the example you posted. You will be getting the number of days between those dates.
So according to your requirement if you want to get the number of days months and years you can use the FM 'HR_GET_TIME_BETWEEN_DATES' or 'FI_PSO_FULL_DAY_MONTH_YEAR_GET'
Regards,
Swapna.