Application Development and Automation 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: 
Read only

Date format...

Former Member
0 Likes
1,487

Hi all,

May I know how to retrieve the day,month and year separately from a data stored in date format. What is the internal structure of date format?

Thanks & regards,

Ananda

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
908

YYYYMMDD

DAY = SY-DATUM+6(2).

MONTH = SY-DATUM+4(2).

YEAR = SY-DATUM+0(4).

7 REPLIES 7
Read only

Former Member
0 Likes
909

YYYYMMDD

DAY = SY-DATUM+6(2).

MONTH = SY-DATUM+4(2).

YEAR = SY-DATUM+0(4).

Read only

Former Member
0 Likes
908

HI Herath,

1. Dates are always stored in YYYYMMDD format only.

2. u can retrive using offset

day = mydate+6(2)

mon = mydate+4(2)

year = mydate(4)

regards,

amit m.

Read only

Former Member
0 Likes
908

Hi,

as it internal format yyyymmdd

then you can try this way..

year = date+0(4).

day = date+6(2).

month = date+4(2).

Regards

vijay

Read only

Simha_
Product and Topic Expert
Product and Topic Expert
0 Likes
908

Hi,

Use this..

s_date = sy-datum.

CONCATENATE s_date6(2) '/' s_date4(2) '/' s_date(4) INTO date_string1.

this way u can move ur date and u can also move them to different variables based on ur requirement.

Cheers,

SImha.

Read only

Former Member
0 Likes
908

Date formatting

The following code demonstrates a number of ways to format a date value:

  • Using the WRITE statement

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

data: gd_date(10).

"field to store output date

  • Converts date from 20020901 to 01.09.2002

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

  • Converts date from 20020901 to 2002/09/01

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

  • Converts date from 20020901 to 01.09.02

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

  • Using data manipulation techniques

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

data: gd_date(8). "field to store output date

  • Converts date from 20010901 to 01092001

gd_date(2) = sy-datum+6(2).

gd_date2(2) = sy-datum4(2).

gd_date+4(4) = sy-datum(4).

  • Using Function modules

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

data: gd_date(8). "field to store output date

  • Converts date from 20010901 to 01SEP2001

gd_date = sy-datum.

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'

EXPORTING

input = gd_date

IMPORTING

OUTPUT = gd_date.

HOPE THIS SOLVES UR PROBLEM. Reward and close teh thraed if ur problem

got solved.

rgds,

Jothi

Read only

Former Member
0 Likes
908

Hai Ananda

Check the following Code

Parameters : P_date(8) type c default '20060225'.

data : day(2) type c,

mon(2) type c,

year(4) type c.

day = p_date+6(2).

mon = p_date+4(2).

year = p_date+0(4).

write 😕 day,

/ mon,

/ year.

Thansk & regards

Sreeni

Read only

Former Member
0 Likes
908

Hi Herath,

Internally date is stored as yyyymmdd. Please check the following,

Data : date type sy-datum,

day(2),

month(2),

year(4).

date = sy-datum.

year = date+0(4).

month = date+4(2).

day = date+6(2).

write : / date, day, month, year.

Hope it helps u.