‎2006 Jun 26 8:53 AM
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
‎2006 Jun 26 8:55 AM
YYYYMMDD
DAY = SY-DATUM+6(2).
MONTH = SY-DATUM+4(2).
YEAR = SY-DATUM+0(4).
‎2006 Jun 26 8:55 AM
YYYYMMDD
DAY = SY-DATUM+6(2).
MONTH = SY-DATUM+4(2).
YEAR = SY-DATUM+0(4).
‎2006 Jun 26 8:55 AM
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.
‎2006 Jun 26 8:57 AM
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
‎2006 Jun 26 8:57 AM
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.
‎2006 Jun 26 8:59 AM
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
‎2006 Jun 26 9:01 AM
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
‎2006 Jun 26 9:14 AM
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.