03-30-2009 1:56 PM
Dear All,
Am working on a 3.1 i version.
Please let me know how i need to find the previous months date from the current date.
i mean current date- 1 month .
This logic will work.
data : w_date like sy-datum.
w_date = sy-daum.
"The statement below will work for everything....
w_date = w_date - 30.
write w:date.
But please tell me how thisis to be handled in case of today.
today being 30th march ,how do i find the one month old date.
Regards,
Abaper.
03-30-2009 1:58 PM
Hi,
Use the FM 'CALCULATE_DATE' if it exists in your version.
Regards,
Bhupal
03-30-2009 1:59 PM
check if this FM exists in ur system: HR_99S_DATE_ADD_SUB_DURATION
03-30-2009 2:00 PM
Set the day of your date field to '01' and subtract then 1 from the date. Now you will have the month in the5th and 6th position without taking care of leap years and year end problems.
03-30-2009 2:00 PM
Am sorry.
Both the above mentioned FMs do not exisit on 3.1i system :-(.
Regs,
Abaper
03-30-2009 2:04 PM
Its not suitable for every condition...
DATA : w_date LIKE sy-datum.
w_date = sy-datum.
w_date+4(2) = w_date+4(2) - 1.
WRITE: sy-datum, / w_date.
03-30-2009 2:05 PM
Are you sure this is working for January?
Heres mine:
wa_date+6(2) = '01'.
wa_date = wa_date - 1.
write:/ wa_date+4(2).
Works with leapyears and years end/start.
Edited by: Rainer Hübenthal on Mar 30, 2009 3:06 PM
03-30-2009 2:01 PM
Hi,
Use FM NUMBER_OF_DAYS_PER_MONTH_GET to get Total number of days in any month of year.
than Minus these from your date using your logic above.
Hope this will solve out your Problem,
Best Regards,
Faisal
03-30-2009 2:02 PM
hi ,
Use this function module to get last month date..
CAll Function 'HR_PT_ADD_MONTH_TO_DATE'
DMM_DATIN 20080202 "The date u want to pass
DMM_COUNT 1 "Number of months you want to deduct
DMM_OPER - " Subtract opertaor
DMM_POS
* The Output
Export parameters Value
DMM_DAOUT 20080102
Regards,
Prabhudas
03-30-2009 2:04 PM
Am sorry.
Both the above mentioned FMs do not exisit on 3.1i system :-(.
Regs,
Abaper
03-30-2009 2:08 PM
hi all,
This does not work for todays date 30-03-2009.(as o jave told earlier. Thisis my major problem)
w_date = sy-datum.
w_date4(2) = w_date4(2) - 1.
WRITE: sy-datum, / w_date.
Regs,
ABAPer.