cancel
Showing results for 
Search instead for 
Did you mean: 

Time and Date mask

Former Member
0 Kudos

Hi

I need to display time in SAP Script according to following format:

8:00 AM - 5:00 PM

Right now its showing 8:00 to 17:00

Moreover I need to display the date as February 26, 2007. I have checked Set Date and Time masks but it didnt work.

Your guidance will be appreciated.

Regards

waseem imran

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

For date check this..


DATA: V_INPUT(8) VALUE '20112006'.

DATA: V_CHAR(25).

data: date type sydatum.
DATA: MONTH_NAMES LIKE T247.

SELECT SINGLE * FROM T247
INTO MONTH_NAMES
WHERE SPRAS = SY-LANGU
AND MNR = V_INPUT+2(2).


CONCATENATE MONTH_NAMES-KTX V_INPUT(2) V_INPUT+4(4)
INTO V_CHAR SEPARATED BY SPACE.

write: / V_CHAR.

Thanks,

Naren

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Pl.refer following material.

Formatting Date Fields: SET DATE MASK Edit section

To define the formatting of date fields, use the SET DATE MASK control command. Executing this command causes all subsequent date fields to be printed using the specified format.

Syntax:

/: SET DATE MASK = 'date_mask'

In the date mask, you can use the following codes:

DD: day (two digits)

DDD: day name - abbreviated

DDDD: day name - written out in full

MM: month (two digits)

MMM: month name - abbreviated

MMMM: month name - written out in full

YY: year (two digits)

YYYY: year (four digits)

LD: day (formatted as for the L option)

LM: month (formatted as for the L option)

LY: year (formatted as for the L option)

All other characters found in a date mask are interpreted as simple text and are copied straight into the output.

Assuming the current system date is March 1st, 1997.

/: SET DATE MASK = 'Foster City, MM/DD/YY'

&DATE& -> Foster City, 03/01/97

/: SET DATE MASK = 'MMMM DD, YYYY'

&DATE& -> March 01, 1997 The date mask may be reset to the default setting by using an empty string:

/: SET DATE MASK = ' '

The abbreviated and full forms of the names of the days and months are stored in the language dependent TTDTG table under the following keys:

%%SAPSCRIPT_DDD_dd: abbreviated day name

%%SAPSCRIPT_DDDD_dd: full form of day name

%%SAPSCRIPT_MMM_mm: abbreviated month name

%%SAPSCRIPT_MMMM_mm: full form of month name

dd: day number 01 = Monday,..., 07 = Sunday

mm: month number 01 = January,..., 12 = December

Formatting Time Fields: SET TIME MASK Edit section

To format time fields to your needs, use the SET TIME MASK control command. Executing this command causes all subsequent time fields to be printed using the specified format.

Syntax:

/: SET TIME MASK = 'time_mask'

In the time mask, you can use the following codes:

HH hours (two digits)

MM minutes (two digits)

SS seconds (two digits)

All other characters found in a time mask are interpreted as simple text and are copied straight into the output.

Assuming the current time is 10:08:12,

/: SET TIME MASK = 'HH:MM'

&TIME& -> 10:08

/: SET TIME MASK = 'HH hours MM minutes'

&TIME& -> 10 hours 08 minutes

The time mask may be reset to the default setting by using an empty string:

/: SET TIME MASK = ' '

Reward, if useful.

Thanks,

USR

Former Member
0 Kudos

Hi,

For time try this..


DATA: v_time TYPE t.
DATA: v_output(10).

v_time = sy-uzeit.

IF v_time > '120000'.
  CONCATENATE v_time(2) ':' v_time+2(2) 'PM' INTO v_output.
ELSE.
  CONCATENATE v_time(2) ':' v_time+2(2) 'AM' INTO v_output.
ENDIF.

WRITE: / v_output.

Thanks

Naren

Former Member
0 Kudos