Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

HOW TO CHANGED MM/DD/YYYY Format to 02-nov-06

Former Member
0 Kudos
142

hi friends i have a query regarding date format in program somebodyhas written the logic as follows.

CONCATENATE SY-DATUM TEXT-T01 SY-UNAME INTO V_TEXT.

here sy-datum format is MM/DD/YYYY.Now my requirement is 02-Nov-06.

any one can suggest me how to do and send the sample code.

Thanks,

Maheedhar.T

1 ACCEPTED SOLUTION

Former Member
0 Kudos
102

just execute this with input as 11/10/2006 ie in MM/DD/YYYY

-


REPORT zex6 no standard page heading. .

PARAMETERS: V_DATUM(11) TYPE C.
  DATA:     V_MON(3) TYPE C,
            V_DAT(2) TYPE C,
            V_YEAR(4) TYPE  C,
            V_MONTHNAME(3) TYPE C,
            V_FULLDATE(30) TYPE C.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
  EXPORTING
    date_external                  = V_DATUM
 IMPORTING
   DATE_INTERNAL                  =  V_DATUM
 EXCEPTIONS
   DATE_EXTERNAL_IS_INVALID       = 1
   OTHERS                         = 2
          .
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'CONVERSION_EXIT_SDATE_INPUT'
  EXPORTING
   input         = v_datum
 IMPORTING
   OUTPUT        = v_datum.

*   write:/ v_datum.

WRITE  V_DATUM+0(2) TO V_MON.
WRITE  V_DATUM+2(2) TO V_DAT.
WRITE  V_DATUM+4(4) TO V_YEAR.


SELECT SINGLE KTX FROM T247 INTO V_MONTHNAME
 WHERE        SPRAS = SY-LANGU
     AND       MNR  = V_MON.


CONCATENATE V_DAT '-' V_MONTHNAME '-' v_YEAR
                  INTO V_FULLDATE ."  SEPARATED BY SPACE.

WRITE:/ V_FULLDATE.

Regards,

Vijay.

Please close the thread once ur query is over ..

7 REPLIES 7

Former Member
0 Kudos
102

Hi,

As per my knowledge You have to Convert the Date into the required format by using offset. means liek taking th offset and storing in the required variable and display in the required format.

Bye

Murthy

Former Member
0 Kudos
102

make use of this FM

<b>CONVERSION_EXIT_IDATE_OUTPUT</b>

Test for function group      SCA1                         
Function module              CONVERSION_EXIT_IDATE_OUTPUT 
Upper/lower case                                                                                
Runtime:        168,586 Microseconds                                                                                
Import parameters               Value                                                                                
INPUT                           20061212                                                                                
Export parameters               Value                                                                                
OUTPUT                          12DEC2006               
                                                        

regards

Prabhu

Former Member
0 Kudos
102

Check this thread out

Regards,

santosh

anversha_s
Active Contributor
0 Kudos
102

Hi,

ry this.

CONVERSION_EXIT_IDATE_OUTPUT


data:lcdate(11).

call function
'converstion_exit_idate_output'
exporting
input = sy-datum
importing
output = lcdate.

concatenate lcdate(2) lcdate+2(3) lcdate+5(4) into lcdate seperated by '-'.

--lcdate is your required format.

sample data ..sy-datum = 20060830
lcdate = 30-AUG-2006

rgds

Anver

Former Member
0 Kudos
102

Hi

Try this way:

data: l_date(15) TYPE C.

CALL FUNCTION 'CONVERSION_EXIT_SDATE_OUTPUT'
  EXPORTING
    INPUT         = sy-datum
 IMPORTING
   OUTPUT        = l_date.

REPLACE ALL OCCURRENCES OF '.' in l_date with '-'.

write:/ l_date.

Kindly close your threads when answered by awarding points.

Kind Regards

Eswar

Former Member
0 Kudos
103

just execute this with input as 11/10/2006 ie in MM/DD/YYYY

-


REPORT zex6 no standard page heading. .

PARAMETERS: V_DATUM(11) TYPE C.
  DATA:     V_MON(3) TYPE C,
            V_DAT(2) TYPE C,
            V_YEAR(4) TYPE  C,
            V_MONTHNAME(3) TYPE C,
            V_FULLDATE(30) TYPE C.

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
  EXPORTING
    date_external                  = V_DATUM
 IMPORTING
   DATE_INTERNAL                  =  V_DATUM
 EXCEPTIONS
   DATE_EXTERNAL_IS_INVALID       = 1
   OTHERS                         = 2
          .
IF sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'CONVERSION_EXIT_SDATE_INPUT'
  EXPORTING
   input         = v_datum
 IMPORTING
   OUTPUT        = v_datum.

*   write:/ v_datum.

WRITE  V_DATUM+0(2) TO V_MON.
WRITE  V_DATUM+2(2) TO V_DAT.
WRITE  V_DATUM+4(4) TO V_YEAR.


SELECT SINGLE KTX FROM T247 INTO V_MONTHNAME
 WHERE        SPRAS = SY-LANGU
     AND       MNR  = V_MON.


CONCATENATE V_DAT '-' V_MONTHNAME '-' v_YEAR
                  INTO V_FULLDATE ."  SEPARATED BY SPACE.

WRITE:/ V_FULLDATE.

Regards,

Vijay.

Please close the thread once ur query is over ..

Former Member
0 Kudos
102

hi,

try this FM

data:v_dat like sy-datum,

v_days(10) type c,

v_month(10) type c,

v_year(10) type c,

v_text like T247-KTX,

v_out(20) type c,

v_date(20) type c.

v_dat = sy-datum.

CALL FUNCTION <b>'HR_IN_GET_DATE_COMPONENTS'</b>

EXPORTING

idate = v_dat

IMPORTING

DAY = v_days

MONTH = v_month

YEAR = v_year

STEXT = v_text

  • LTEXT = v_text

USERDATE = v_date

EXCEPTIONS

INPUT_DATE_IS_INITIAL = 1

TEXT_FOR_MONTH_NOT_MAINTAINED = 2

OTHERS = 3

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

else.

concatenate v_days '-' v_text '-' v_year+2(2) into v_out.

ENDIF.

write:/ v_out.

Do assign points if it helps you