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: 

Date Format

Former Member
0 Kudos
111

how to change the Date format 20070402 to 02/04/2007.

Please provide the logic.

6 REPLIES 6

Former Member
0 Kudos
86

constants : c_backslash type c value '/'.

data : v_dat type sy-datum,

v_dat1 type char10.

concatenate v_dat+6(2)

c_backslah

v_dat+4(2)

c_backslash

v_dat+0(4)

into

v_dat1.

Former Member
0 Kudos
86

Hi,

Check the following code:

DATA: VDATE(10) TYPE C

CONCATENATE sy-datum6(2) sy-datum4(2)

sy-datum+0(4) INTO VDATE

SEPARATED BY '/'.

Hope this helps.

Reward if helpful.

regards,

Sipra

Former Member
0 Kudos
86

data: v1(2) type c,

v2(2) type c,

v3(4) type c,

v_date(10) type c.

v1 = date+6(2).

v2 = date+4(2).

v3 = date+0(4).

concatenate v1 v2 v3 into v_date separated by '/'.

write:/ v_date.

Former Member
0 Kudos
86

Hi,

data: date_form type CHAR10.

call function 'HRGPBS_HESA_DATE_FORMAT'

exporting

P_DATE = sy-datum

importing

DATESTRING = date_form

exceptions

others = 1.

OR Using WRITE Stmt ->

  • Converts date from 20070402 to 02/04/2007

write sy-datum to gd_date dd/mm/yyyy.

Check the links->

Former Member
0 Kudos
86

HI

Date = YYYYMMDD

Concatenate date4(2) ‘ /’ date6(2) ‘/’ date(4) into Date2.

or

data : l_date(10) type c .

concatenate sy-datum6(2) '/' sy-datum4(2) '/' sy-datum(4) into l_date.

write : l_date.

or

data :l_date(10) type c

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

DATE_INTERNAL = SY-DATUM

IMPORTING

DATE_EXTERNAL = l_date.

this function module converts date from 20050601 to external format which is specified in user profile.

or

PARAMETERS: P_DATE LIKE SY-DATUM.

DATA: T_MONTHS LIKE STANDARD TABLE OF T247 WITH HEADER LINE.

DATA: DATE LIKE AUSP-ATWRT.

CALL FUNCTION 'MONTH_NAMES_GET'

TABLES

MONTH_NAMES = T_MONTHS.

READ TABLE T_MONTHS WITH KEY MNR = P_DATE+4(2).

DATE(2) = P_DATE+6(2).

DATE+2(3) = T_MONTHS-KTX.

DATE5(2) = P_DATE2(2).

WRITE DATE.

Regards

Laxmi

Former Member
0 Kudos
86

Hi Vamsi,

DATA: date(10),

v1(2) ,

v2(2),

v3(4),

v_date(10).

date = 20070402.

v1 = date+6(2). " it writes 02

v2 = date+4(2). " it writes 04

v3 = date+0(4). " it writes 2007

concatenate v1 v2 v3 into v_date separated by '/'.

write:/ v_date.

Regards,

KK