Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: How do I define a Nullable DateTime variable in Visual COBOL ?

$
0
0

The System.Nullable generic should do what you want. You can use that in COBOL with code such as:-

       program-id. Program1 as "Nullable.Program1".

       data division.
       working-storage section.
       01  ws-datetime     type System.Nullable[type System.DateTime].

       procedure division.
      
           set ws-datetime to new type System.Nullable[type System.DateTime]
           display ws-datetime::HasValue
           if ws-datetime::HasValue
               display "DateTime has Value."
           else
               display "DateTime is NULL."
           end-if              
           set ws-datetime to type System.DateTime::Now
           display ws-datetime::HasValue
           if ws-datetime::HasValue
               display "DateTime has Value."
           else
               display "DateTime is NULL."
           end-if              

           goback.
          
       end program Program1.

The HasValue property indicates if the type variable is null.

 

 


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>