//Input String yyyymmdd
var date_string = '20200101'
//Create date object
var oDate = new Date(date_string.substr(0, 4), date_string.substr(4, 2), date_string.substr(6, 2))
oDate.setMonth(oDate.getMonth() - 1)
var year = oDate.getFullYear().toString()
var month = oDate.getMonth().toString()
var day = oDate.getDay().toString()
//Add leading zero's
if (month.length === 1 ) {
month = '0' + month
}
if (day.length === 1 ) {
day = '0' + day
}
//Return string: 20191201
var sDate = year + month + day
Tag: month
[ABAP] Get month name
METHOD get_month_name.
DATA: month_names TYPE TABLE OF t247.
CALL FUNCTION 'MONTH_NAMES_GET'
TABLES
month_names = month_names
EXCEPTIONS
OTHERS = 0.
TRY.
r_name = month_names[ mnr = i_month ]-ltx.
CATCH cx_sy_itab_line_not_found.
ENDTRY.
ENDMETHOD.