cancel
Showing results for 
Search instead for 
Did you mean: 

Date Conversion

Former Member
0 Kudos

Hi Gurus ,

I am Working on webdynpro application . User entering date in formate mmddyyyy . I want to convert it in ddmmyyyy . there is any way to convert it .

I want to mention .

1. I can,t use offset for this .( This is restricted ) .

2. Fm date_convert_to_internal not working for this. i have checked already .

3.  Fm date_convert_to_external not working for this. i have checked already .

Thanks in Advance .....

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

, kindly response to this thread. Is your problem is solved, if yes . then kindly close the thread my marking ans as correct and helpful. so that if someone having same problem can use the solutions from this.

farooq_basha
Active Participant
0 Kudos

Hi Devesh,

If u dont want to use offset then check with below things.

1)

Use the FM <b>/SAPDMC/LSM_DATE_CONVERT</b>.

Pass DATE_IN = 10/16/2005

DATE_FORMAT_IN    = DMDY

TO_OUTPUT_FORMAT  = BLANK

TO_INTERNAL_FORMAT = X

OUTPUT

DATE_OUT   = 20051016

2)


*   Convert date 1/3/9999 into 99990301
    CALL FUNCTION 'CONVERSION_EXIT_SDATE_INPUT'
      EXPORTING
        input  = w_inputfile-endda
      IMPORTING
        output = w_inputfile-endda.

*   Convert date 99990301 into 01/03/9999
    CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
      EXPORTING
        input  = w_inputfile-endda
      IMPORTING
        output = w_inputfile-endda.

3)

http://scn.sap.com/thread/1030380

Check above ways, will done.

Regards

Farooq

Former Member
0 Kudos

Hello,

try this code.

DATA:

  lv_input      TYPE dats,                "Input. (yyyymmdd)
lv_output    
TYPE string,              "Output. (DD/MM/YYYY)
lv_date1     
TYPE char2,
lv_date2     
TYPE char2,
lv_date3     
TYPE char4,
lv_len       
TYPE i.

lv_input
= sy-datum.  

" Here i am giving today's date means sy-datum

provide today's date. Here you can give input like  20130930  means (30.sept.2013)


lv_len
= strlen( lv_input ). 

" here we are handling some error. Suppose you gave input less then 8 char.


lv_output 
lv_input.
IF lv_input IS NOT INITIAL .
IF lv_len EQ 8.
CLEAR lv_output.
lv_date3
= lv_input+0(4). " Here we are finding year
lv_date2
= lv_input+4(2). " Here we are finding Month
lv_date1
= lv_input+6(2).     " Here we are finding day

" Here we are Concatenating all day month and year.
CONCATENATE lv_date1 lv_date2 lv_date3 INTO lv_output SEPARATED BY '/'.


Write: Lv_output.

CLEAR : lv_date3, lv_date2,lv_date1.
ENDIF.
ENDIF.

**************************************************************************************************************

One small concept you need to learn. Rest of all Example you can do by yourself.

Let my LV_date is type dats(Char8). And input is coming like yyyymmdd.

Now make a lv_date_new type string which will keep modified date.

data:

lv_year type char4,

lv_month type char2,

lv_day type char2,

lv_date_new type string.

lv_day = lv_date+6(2).

" In  the statement we are fetching data from lv_date start with 6th  character and next 2 character.means we will start from M to DD.  so now  lv_day will carry DD. so now you can fetch month lv_date+4(2) and year  lv_date+0(4) with same concept.

"now concatenate your all data day month year separated by . or / or -

lv_month = lv_date+4(2).

lv_year = lv_date+0(4).

concatenate lv_day lv_month lv_year intolv_date_new.                                ddmmyyyy.

concatenate lv_day lv_month lv_year into lv_date_new separated by '/' .       dd/mm/yyyy.

BR

ChanS

p.s.: For more information 

FUNCTION MODULE FOR CONVERTING DATE INTO THE GIVEN FORMAT - Code Gallery - SCN Wiki