Highlighted
Absent Member.
Absent Member.
190 views

[archive] Shows only time in Date Control?

[Migrated content. Thread originally posted on 17 December 2008]

Hi

Can I use the date controle to show only time instead of date, like 10:30:20 AM or 02:30 PM. Is there any sample program? If anybody has sample, please help me.

Thanks in advance 🙂
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Shows only time in Date Control?

If you just want to show a time, why don't you just use a label or entry field?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Shows only time in Date Control?

just use a plain entry field and format the time yourself, here is a quick sample I thru together. It should display time like 9:10 AM, modify the DISP-TIME to suit yoru needs. I didn't test it tho 😉

Oh on a side note, you can use the microsoft OCX DTPicker to allow Times only, we use it for Date's mostly but I noticed you can have it do dates, times, or dates & times.


       01 WS-TIME               PIC 9(8)    VALUE IS ZEROS.
       01 WS-TIME-RE REDEFINES WS-TIME.
           02 WS-TIME-6         PIC 9(6).
           02 WS-TIME-6-RE REDEFINES WS-TIME-6.
               03 WS-HOUR       PIC 99.
               03 WS-MIN        PIC 99.
               03 WS-SEC        PIC 99.
           02 WS-MSEC           PIC 99.

       01 SM-DISP-TIME.
           03 SM-DISP-HOUR      PIC Z9.
           03 FILLER          PIC X      VALUE IS ":".
           03 SM-DISP-MIN        PIC 99.
           03 FILLER          PIC X      VALUE IS SPACES.
           03 SM-DISP-AMPM      PIC XX.
.
.
.
           ACCEPT WS-TIME FROM TIME.
           MOVE "AM"      TO SM-DISP-AMPM.
           IF WS-HOUR > 11
              SUBTRACT 12 FROM WS-HOUR
              MOVE "PM" TO SM-DISP-AMPM
           END-IF.
           IF WS-HOUR = ZEROS
              MOVE 12 TO WS-HOUR
           END-IF.
           MOVE WS-HOUR            TO SM-DISP-HOUR.
           MOVE WS-MIN              TO SM-DISP-MIN.
           MODIFY YOUR_ENTRY_FIELD, VALUE SM-DISP-TIME.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.