Skip to main content

[archive] Shows only time in Date Control?

  • December 17, 2008
  • 2 replies
  • 0 views

[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 :)

2 replies

[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 :)
If you just want to show a time, why don't you just use a label or entry field?

[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 :)
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.