10-24-2005 6:08 AM
Hi,
I would like to convert date from any format to YYYYMM.
Could any one suggest me how to go about?
10-24-2005 6:42 AM
system keeps the dates in YYYYMMDD format (as long as the field is of type D). so you dont have to do anything special to convert. in your case you wanted YYYYMM which is bascially offsetting for which you can follow the answers given by others in the thread.
Regards
Raja
10-24-2005 6:12 AM
Hi,
Pl use the function module
CONVERT_DATE_TO_INTERN_FORMAT
Else
You declare the target field as type date, and directly move your source field into the target, SAP will automatically convert the target into internal format.
Regards
Elini.P
10-24-2005 6:14 AM
Hi,
Try this
WRITE: sy-datum,
/ sy-datum yymmdd.
Thanks&Regards,
Ruthra
10-24-2005 6:15 AM
Hi Anu,
its very much possible , but you must know whath the date format is given to you as input.
for example if its like sy-datum (YYYYMMDD).
you simply have to store the first six digit of the date into strng type variable:
data: input_date like sy-datum value '20051231'. "31st dec of 2005
data: str(6).
str = input_date(6).
write str.
thats it. you also can use some mask like ____/__/ for another solution. but you must do the coding specific to input format. that is if its YYYYMMDD your code will be as i have given, but if it is YYYYDDMM or DDMMYYYY, the code will be diffrent. there is no generic solution i think.
10-24-2005 6:36 AM
use function module CONVERT_DATE_TO_INTERNAL
and then read the first 6 characters...
eg:
DATA l_date(10) TYPE c.
DATA lt TYPE sy-datum.
l_date = '24.10.2005'.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = l_date
IMPORTING
date_internal = lt
EXCEPTIONS
DATE_EXTERNAL_IS_INVALID = 1
OTHERS = 2
.
WRITE 😕 lt+0(6).
rgds,
PJ
Message was edited by: Priyank Jain
10-24-2005 6:42 AM
system keeps the dates in YYYYMMDD format (as long as the field is of type D). so you dont have to do anything special to convert. in your case you wanted YYYYMM which is bascially offsetting for which you can follow the answers given by others in the thread.
Regards
Raja
10-24-2005 6:55 AM
hi,
use can use the function modules mentioned above or use
the concatenate statement.
eg. date entered in format yyyymmdd say 20051024
data : w_date like sy-datum.
CONCATENATE w_date0(4) w_date4(2) iNTO w_date.
Hope this helps.
regards,
kavita joshi.