Skip to main content

Problem:

The formatDateToOLE method in the olesup class only supports putting dates into a OLE Date.

The OLE date format uses a floating point number with the decimal portion representing the time portion.

Resolution:

You can manually enter the time format into the OLE date field using code such as:-

        program-id. "ConvertDateToOLE".

      *****************************************************************

      *

      *    Program         ConvertDateToOLE

      *

      *    Author          davs - MicroFocus SupportLine

      *

      *    This module will convert a date/time into the OLE date

      *    format (VT_DATE). The Date portion is the whole number

      *    and the time is the decimal portion.

      *

      *    We will use an existing routine for the date portion and

      *    calculate the time portion ourselves.

      *

      *****************************************************************

       class-control.

           olesup is class "olesup"

           .

       working-storage section.

       01  ws-time                     comp-2.

       linkage section.

       01  lnk-Day                     pic 99.

       01  lnk-month                   pic 99.

       01  lnk-year                    pic 9(4).

       01  lnk-hours                   pic 99.

       01  lnk-mins                    pic 99.

       01  lnk-secs                    pic 99.

       01  lnk-oledate                 comp-2.

       01  lnk-result                  pic s9(9) comp-5.

       procedure division using by reference lnk-Day

                                             lnk-month

                                             lnk-year

                                             lnk-hours

                                             lnk-mins

                                             lnk-secs

                                             lnk-oledate. *> Output

       start-section section.

           invoke olesup "formatDateToOLE" using lnk-Day

                                                 lnk-Month

                                                 lnk-Year

                                                 lnk-oledate

           compute ws-time =

         ((lnk-hours (((lnk-mins * 60) lnk-secs) / 3600) ) )

                       / 24

           end-compute

           compute lnk-oledate = lnk-oledate ws-time

           goback.

Old KB# 1264