‎2008 Apr 23 8:14 AM
The date is displayed in the format 23.04.2008 and i want to display it as " Wednesday, April 23, 2008 ".
Also the time is displayed as 12:23:01 and i want to display it as " 12:23 PM ".
How do i do it.
‎2008 Apr 23 2:32 PM
Hi,
Use the below code.
parameters: p_date type sy-datum default sy-datum,
p_time type sy-uzeit default sy-uzeit.
data: v_DAYTXT like HRVSCHED-DAYTXT,
v_month like t247-ltx,
v_text(50),
v_space(2) value ' ',
v_time(10).
CALL FUNCTION 'RH_GET_DATE_DAYNAME'
EXPORTING
LANGU = sy-langu
DATE = P_DATE
IMPORTING
DAYTXT = v_DAYTXT
EXCEPTIONS
NO_LANGU = 1
NO_DATE = 2
NO_DAYTXT_FOR_LANGU = 3
INVALID_DATE = 4
OTHERS = 5
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
data: month_names LIKE t247 OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
language = sy-langu
TABLES
month_names = month_names
EXCEPTIONS
month_names_not_found = 1
OTHERS = 2.
read table month_names with key mnr = p_date+4(2).
if sy-subrc = 0.
v_month = month_names-ltx.
endif.
concatenate: v_daytxt ',' into v_daytxt,
v_Month p_date+6(2) into v_month separated by space,
v_month ',' into v_month.
concatenate v_daytxt v_month p_date+0(4) into v_text separated by space.
if p_time+0(2) ge '12'.
concatenate: p_time0(2) ':' p_time2(2) into v_time,
v_time 'PM' into v_time separated by space.
else.
concatenate: p_time0(2) ':' p_time2(2) into v_time,
v_time 'AM' into v_time separated by space.
endif.
write:/ v_text.
write:/ v_time.
‎2008 Apr 23 1:49 PM
Hi,
try this:
REPORT zhabitest3 .
PARAMETER:
dat LIKE sy-datum,
tim LIKE sy-uzeit.
DATA:
str_dat(32),
str_tim(16).
PERFORM trim_date USING dat
CHANGING str_dat.
WRITE / str_dat.
PERFORM trim_time USING tim
CHANGING str_tim.
WRITE / str_tim.
&----
*& Form TRIM_DATE
&----
FORM trim_date USING x TYPE sydatum
CHANGING str.
DATA:
daystr(20),
monstr(20),
tmpstr(32),
wotnr TYPE p.
daystr = 'Wednesday'.
CALL FUNCTION 'DAY_IN_WEEK'
EXPORTING
datum = x
IMPORTING
wotnr = wotnr.
CASE wotnr.
WHEN 1. daystr = 'Monday'.
WHEN 2. daystr = 'Tuesday'.
WHEN 3. daystr = 'Wednesday'.
WHEN 4. daystr = 'Thursday'.
WHEN 5. daystr = 'Friday'.
WHEN 6. daystr = 'Saturday'.
WHEN 7. daystr = 'Sunday'.
ENDCASE.
CASE x+4(2).
WHEN '01'. monstr = 'January'.
WHEN '02'. monstr = 'February'.
WHEN '03'. monstr = 'March'.
WHEN '04'. monstr = 'April'.
WHEN '05'. monstr = 'May'.
WHEN '06'. monstr = 'June'.
WHEN '07'. monstr = 'July'.
WHEN '08'. monstr = 'August'.
WHEN '09'. monstr = 'September'.
WHEN '10'. monstr = 'October'.
WHEN '11'. monstr = 'November'.
WHEN '12'. monstr = 'December'.
ENDCASE.
CONCATENATE daystr ',' INTO tmpstr.
CONCATENATE tmpstr monstr INTO str SEPARATED BY space.
CONCATENATE str ',' INTO tmpstr.
CONCATENATE tmpstr x+0(4) INTO str SEPARATED BY space.
ENDFORM. " TRIM_DATE
&----
*& Form TRIM_TIME
&----
FORM trim_time USING x TYPE syuzeit
CHANGING str.
DATA:
daystr(20),
monstr(20),
tmpstr(32).
CONCATENATE x0(2) ':' x2(2) INTO tmpstr.
IF x+0(2) > 12.
CONCATENATE tmpstr 'PM' INTO str SEPARATED BY space.
ELSE.
CONCATENATE tmpstr 'AM' INTO str SEPARATED BY space.
ENDIF.
ENDFORM. " TRIM_TIME
With kind regards
Walter Habich
‎2008 Apr 23 2:32 PM
Hi,
Use the below code.
parameters: p_date type sy-datum default sy-datum,
p_time type sy-uzeit default sy-uzeit.
data: v_DAYTXT like HRVSCHED-DAYTXT,
v_month like t247-ltx,
v_text(50),
v_space(2) value ' ',
v_time(10).
CALL FUNCTION 'RH_GET_DATE_DAYNAME'
EXPORTING
LANGU = sy-langu
DATE = P_DATE
IMPORTING
DAYTXT = v_DAYTXT
EXCEPTIONS
NO_LANGU = 1
NO_DATE = 2
NO_DAYTXT_FOR_LANGU = 3
INVALID_DATE = 4
OTHERS = 5
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
data: month_names LIKE t247 OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
language = sy-langu
TABLES
month_names = month_names
EXCEPTIONS
month_names_not_found = 1
OTHERS = 2.
read table month_names with key mnr = p_date+4(2).
if sy-subrc = 0.
v_month = month_names-ltx.
endif.
concatenate: v_daytxt ',' into v_daytxt,
v_Month p_date+6(2) into v_month separated by space,
v_month ',' into v_month.
concatenate v_daytxt v_month p_date+0(4) into v_text separated by space.
if p_time+0(2) ge '12'.
concatenate: p_time0(2) ':' p_time2(2) into v_time,
v_time 'PM' into v_time separated by space.
else.
concatenate: p_time0(2) ':' p_time2(2) into v_time,
v_time 'AM' into v_time separated by space.
endif.
write:/ v_text.
write:/ v_time.
‎2008 Apr 30 7:15 AM
‎2008 Apr 23 2:40 PM
hi for date :
use FM ISH_GET_DAY_OF_WEEK . Pass date you will get week day.
use ISP_GET_MONTH_NAME to get month.
now you can print date in desired format.
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 23, 2008 11:09 AM