2007 Jun 19 6:34 AM
Hi all. I want to perform some calculations on DATE.
Say for eg. I want to calculate a date 100 days before the current date or say a date 250 days ahead of todays date. Is there a function module for that?
PLEASE give some sample code for the function module - how to use that FM.
Thanks
Ribhu
Hi all. I want to perform some calculations on DATE.
Say for eg. I want to calculate a date 100 days before the current date or say a date 250 days ahead of todays date. Is there a function module for that?
PLEASE give some sample code for the function module - how to use that FM.
Thanks
Ribhu
2007 Jun 19 6:36 AM
Hi,
You can use just addition or subtraction on data types of D
check this example.
DATA: V_DATE TYPE SYDATUM.
V_DATE = SY-DATUM. " current date.
* Move to 100 days before.
V_DATE = V_DATE - 100.
WRITE: / v_date. " 100 days before.
V_DATE = SY-DATUM.
* Move to 250 days after.
V_DATE = V_DATE + 250.
WRITE: / v_date. " 250 days after.
Thanks
Naren
2007 Jun 19 6:40 AM
Hi,
Use FM 'DATE_IN_FUTURE'.
For previous period,
ANZAHL_TAGE <b>-</b>30
IMPORT_DATUM 23.06.2007
For future period,
ANZAHL_TAGE <b>+</b>30
IMPORT_DATUM 23.06.2007
Message was edited by:
Jayanthi Jayaraman
2007 Jun 19 8:22 AM
Hi Jayanthi,
I think I saw some of ur white papers on smartforms b4 . My g mail address is [email protected] . Whats ur g mail address?
One concern - suppose I wanna find a date 200 months back the current date or any date stored in a variable - how to do that??
Thanks
Ribhu
2007 Jun 19 8:25 AM
hi,
Just execute this sample report.
data : wa_date type sy-datum.
call function 'RP_CALC_DATE_IN_INTERVAL'
exporting
date = sy-datum
days = 0 " --------------------> give ur required date
months = 200 "--------------------> give ur required month
years = 0 " --------------------> give ur required years
signum = '-'
importing
calc_date = wa_date.
write :/ wa_date. " new minised date
Rgds
Anversha
2007 Jun 19 6:46 AM
Hi Ribhu,
Calculation on dates can be just done as arithematic calculation in SAP.
For e.g
data date type sy-datum.
date = sy-datum - 15.
will give you a date 15 days before the current date.
Reward points if useful.
Regards,
Atish
2007 Jun 19 6:51 AM
here is the sample code for your exactly for 100 days before .
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.
EDAYS = EDAYS .
WRITE:/ 'Difference in Days ', EDAYS.
*WRITE:/ 'Difference in Months ', emonths.
*WRITE:/ 'Difference in Years ', EYEARS.
INITIALIZATION.
FROMDATE = SY-DATUM - 100 .reward points if it is usefull ..
Girish
2007 Jun 19 7:00 AM
hi,
use this FM.
data : wa_date type sy-datum.
call function 'RP_CALC_DATE_IN_INTERVAL'
exporting
date = sy-datum
days = 20 " --------------------> give ur required date
months = 0 "--------------------> give ur required month
years = 0 " --------------------> give ur required years
signum = '-'
importing
calc_date = wa_date.
write :/ wa_date. " new minised date
"Note
"signum = '+' "
"signum = '-' "
Rgds
Anversha
2007 Jun 19 8:29 AM
hi ribhu,
use this function module 'SD_DATETIME_DIFFERENCE' hope this may help u...
please reward incase usefull...
regards,
prashant
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |