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

Time Format

Former Member
0 Likes
683

Dear Friends,

I have the requirement that user will input in screen 12 hours (01:10 PM) format for time rather than 24 hours format (13:10). Similarly, the time mask should be 12 hours fomat than 24 hours.

Any clues with anybody.

Regards,

Deva.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
613

Hi,

Try the FM: <b>HRVE_CONVERT_TIME</b>

TYPE_TIME A ( Use 'B' for the other format)

INPUT_TIME 13:00:00

INPUT_AM_PM AM

Export parameters Value

OUTPUT_TIME 01:00:00

OUTPUT_AM_PM PM

Also Try these sample codes:

data: time type sy-uzeit value '073000'.

data TIMEC(6).

data h1 type P DECIMALS 1.

data h2 type P DECIMALS 1.

data h3 type P DECIMALS 1.

data hours type P DECIMALS 1.

move time to timeC.

MOVE TIMEC(2) TO H1.

MOVE TIMEC+2(2) TO H2.

MOVE TIMEC+4(2) TO H3.

hours = h1 + ( h2 / 60 ) + ( H3 / 3600 ).

write:/ hours.

The below code ignores the seconds. The hours are in 24 hour format.

DATA: v_tims LIKE sy-uzeit,

v_hrs TYPE p decimals 1.

START-OF-SELECTION.

v_tims = sy-uzeit.

v_hrs = v_tims+0(2) + ( v_tims+2(2) / 60 ).

WRITE: v_hrs.

Regards,

Anjali

4 REPLIES 4
Read only

Former Member
0 Likes
613

Well, it sounds like you'll have to have a radio button or checkbox for AM/PM and you'll then either have to convert that to 24 hour time to store on the database or leave it in 12 hour format and also store whether it's AM or PM in a separate field. Is that what you're asking?

rob

Read only

Former Member
0 Likes
613

Hi,

Use SET command controls the time field format

For details on SET command Click on the below link:

http://dev.mysql.com/doc/maxdb/en/78/ac9b41aa6ca309e10000000a155106/content.htm

Thanks,

Naga

Read only

Former Member
0 Likes
614

Hi,

Try the FM: <b>HRVE_CONVERT_TIME</b>

TYPE_TIME A ( Use 'B' for the other format)

INPUT_TIME 13:00:00

INPUT_AM_PM AM

Export parameters Value

OUTPUT_TIME 01:00:00

OUTPUT_AM_PM PM

Also Try these sample codes:

data: time type sy-uzeit value '073000'.

data TIMEC(6).

data h1 type P DECIMALS 1.

data h2 type P DECIMALS 1.

data h3 type P DECIMALS 1.

data hours type P DECIMALS 1.

move time to timeC.

MOVE TIMEC(2) TO H1.

MOVE TIMEC+2(2) TO H2.

MOVE TIMEC+4(2) TO H3.

hours = h1 + ( h2 / 60 ) + ( H3 / 3600 ).

write:/ hours.

The below code ignores the seconds. The hours are in 24 hour format.

DATA: v_tims LIKE sy-uzeit,

v_hrs TYPE p decimals 1.

START-OF-SELECTION.

v_tims = sy-uzeit.

v_hrs = v_tims+0(2) + ( v_tims+2(2) / 60 ).

WRITE: v_hrs.

Regards,

Anjali

Read only

0 Likes
613

Dear Anjali,

The FM works fine.

I'll redefine my problem. I want the input in my selection screen in AM/PM format. And print the same in my output (report). This function module HRVE_CONVERT_TIME works fine to print the values but can something be done for the selection screen.

Please help me out.

Regards,

Deva.