‎2005 Jul 22 7:06 AM
HI frendz,
I have to retrieve data considering the date range.I have to check a date in the where condition which should within the last 12 months.So my one interval will be sydatum but how can i get the other interval ie 1 year back date ?? Is there any std function module which gives one year back date if we give the present date. Pls help me out in this ASAP...
‎2005 Jul 22 7:12 AM
Hi,
Use date_in_future . Give the date in Import_datum parameter and give -365 in anzahl_tage .You can see the output.But for leap year , you need to take care.
‎2005 Jul 22 7:21 AM
hi,
try that:
yr_back_date = sy-datum .
SUBTRACT 1 FROM yr_back_date+3(1).
regards Andreas
‎2005 Jul 22 7:57 AM
hi
try this
CALL FUNCTION 'BKK_ADD_MONTH_TO_DATE'
EXPORTING
months = -12
olddate = sy-datum
IMPORTING
NEWDATE = dt_new
.
dt_new gives u a 12 month previous date
check out my reply in this post for some more function modules...
https://www.sdn.sap.com/sdn/collaboration.sdn?node=linkFnode6-1&contenttype=url&content=https://
regards,
PJ
‎2005 Jul 22 8:02 AM
oops !!
sorry i led u to the wrong post...
here are some more function modules...
RE_ADD_MONTH_TO_DATE
HR_JP_ADD_MONTH_TO_DATE
/BEV4/PLPS__ADD_MONTH_TO_DATE
/BEV3/CHPS__ADD_MONTH_TO_DATE
there are more....u can search...
regards,
PJ
‎2005 Oct 18 12:59 PM
Hello Priyank,
I am not able to access any one of the function modules which you mentioned.
My requirement is to do operations on date. How can I achive it ?
For example I need to add 2years 3months 4 days to current date and similarly I need suggestions about operations on time.
Thanks in advance.
Regards,
Arvind...
‎2005 Oct 18 1:15 PM
‎2005 Jul 22 8:03 AM
Hi Nagarjuna,
In general, when we say the data one year back, we take the date one day after the current date and one year before the current year -
For example - If today is 22nd July 2005, one year back, the date should be taken as 23rd july 2004.
Look at the following snippet of code -
PARAMETERS : PRESENT TYPE D.
DATA : BEGIN OF PAST_DATE,
YEAR(4) TYPE N,
MONTH(2) TYPE N,
DAY(2) TYPE N,
END OF PAST_DATE.
DATA : ONE_YEAR_BACK TYPE D.
MOVE PRESENT TO PAST_DATE.
SUBTRACT 1 FROM PAST_DATE-YEAR.
ADD 1 TO PAST_DATE-DAY.
MOVE PAST_DATE TO ONE_YEAR_BACK.hope that helps.
Regards,
Anand Mandalika.
‎2005 Jul 22 9:01 AM
Hi PJ,
your function module looks like the best solution.
Andreas, what happens, when your calculation starts on 20040229? -> 20030229?!
Anand Mandalika, you are not longer calculation on date fields, I tried 20050731 -> 20050732!
Regards,
Christian
‎2005 Jul 22 9:45 AM
O.K. Christian,
IF datum+4 = '0229'.
yr_back_date = datum - 1.
ELSE.
yr_back_date = datum .
ENDIF.
SUBTRACT 1 FROM yr_back_date+3(1).Andreas
‎2005 Oct 18 1:21 PM
Hi,
Christians comment on Anand Mandalika's code is correct.
Since Dates are only integers with a mask the code can be corrected as follows:
PARAMETERS : PRESENT TYPE D.
DATA : BEGIN OF PAST_DATE,
YEAR(4) TYPE N,
MONTH(2) TYPE N,
DAY(2) TYPE N,
END OF PAST_DATE.
DATA : ONE_YEAR_BACK TYPE D.
MOVE PRESENT TO PAST_DATE.
SUBTRACT 1 FROM PAST_DATE-YEAR.
MOVE PAST_DATE TO ONE_YEAR_BACK.
ADD 1 TO ONE_YEAR_BACK.
Message was edited by: Erik Verbeeck