2009 Apr 01 11:49 AM
Hi,
I have a requiremnt where i need to change the date format to yyyymmdd..I have treid using the WRITE TO statement but it didn't work.
suppose i got the field value as 05082008(ddmmyyyy), i need to write as (20080805)(yyyymmdd).
I tried the bewlo statemnt.
write : lv_date1 to lv_date yymmdd.It didn't worked..
can anyone suggest me.
Regards,
Raj
2009 Apr 01 11:52 AM
hi,
use offset and get day, month and year seperately..
then use concatenate to get output in desired format.
Rgds.,
subash
Hi,
I have a requiremnt where i need to change the date format to yyyymmdd..I have treid using the WRITE TO statement but it didn't work.
suppose i got the field value as 05082008(ddmmyyyy), i need to write as (20080805)(yyyymmdd).
I tried the bewlo statemnt.
write : lv_date1 to lv_date yymmdd.It didn't worked..
can anyone suggest me.
Regards,
Raj
2009 Apr 01 11:52 AM
hi,
use offset and get day, month and year seperately..
then use concatenate to get output in desired format.
Rgds.,
subash
2009 Apr 01 11:55 AM
Hi,
I also done that but there is a problem with the user's own data..It may change from user to user...
for one user am getting yyyyddmm and for one user am getting yyyymmdd..In this case how to offset the values and conncatenate to get the format as yyyymmdd.
Regards,
raj
2009 Apr 01 12:02 PM
Kumar,
Pass the username to USR01 table and check DATFM field...
this DATFM field will have the data format details for a given user.
say 1-> for DDMMYYYY and 2 for -->YYYYMMDD etc.,
Based on these you can write ur code for concatenation
example:
if datfm = 2.
concatenate sy-datum0(4) sy-datum4(2) sy-datum+6(2) into v_date.
endif.
Regards,
Aswin.
2009 Apr 01 12:03 PM
Hi,
I had done small change in the code reagrding the offsetting and it worked...
Regards,
Raj
2009 Apr 01 12:03 PM
try like this...
data : date(8).
data: d1(8)."[this is ur date field]
date0(4) = d1 0(4)."yyyy
date4(2) = d1 4(2)."mm
date6(2) = d16(2). "dd
write: / date.
change offset accordindly.
2009 Apr 01 12:05 PM
Hi,
first u get the user data format from USR01 table field DATFM, then u do the CONCATENATION bassed on the format..
eg:
**To Know the Date Format for the user name in user master record
SELECT SINGLE datfm FROM usr01
INTO v_datfm
WHERE bname = sy-uname.
CASE v_datfm.
WHEN 1.
CONCATENATE it_final-vdatu3(2) '.' it_final-vdatu0(2) '.' it_final-vdatu+6(4) INTO it_final-vdatu.
WHEN 2.
CONCATENATE it_final-vdatu0(2) '/' it_final-vdatu3(2) '/' it_final-vdatu+6(4) INTO it_final-vdatu.
WHEN 3.
CONCATENATE it_final-vdatu0(2) '-' it_final-vdatu3(2) '-' it_final-vdatu+6(4) INTO it_final-vdatu.
WHEN 4.
CONCATENATE it_final-vdatu6(4) '.' it_final-vdatu0(2) '.' it_final-vdatu+3(2) INTO it_final-vdatu.
WHEN 5.
CONCATENATE it_final-vdatu6(4) '/' it_final-vdatu0(2) '/' it_final-vdatu+3(2) INTO it_final-vdatu.
WHEN 6.
CONCATENATE it_final-vdatu6(4) '-' it_final-vdatu0(2) '-' it_final-vdatu+3(2) INTO it_final-vdatu.
endcase.
Regards,
Pavan
2009 Apr 01 12:22 PM