×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

COBOL General discussion FAQ

Functions

How to conduct arthimetic operations on the current date and time by GC1CEO
Posted: 4 Mar 01

First, to get the current date and time (Y2K compliant), the function name is current-date (this covers BOTH date and time), first you need to seperate it into different parts if you want to perform operations with them, for example if you wish to compare the current year to a number in storage. In your working storage section you want to define the following:

01 DATE-IN.
   05 YEAR-IN             PIC 99.
   05 MONTH-IN            PIC 99.
   05 DATE-IN             PIC 99.
   05 HOUR-IN             PIC 99.
   05 MINUTE-IN           PIC 99.

Take in mind, that the time is listed in Zulu time (24 hour format) so you will have to do some operations to convert it to the 12 hour format.

In the procedure division, just do:

MOVE FUNCTION CURRENT-DATE TO DATE-IN.

Since your DATE-IN is seperated into its different (and properly sized) sections in the Working Storage section, then you simply use the specific identifier you wish to conduct operations on, for example:

COMPUTE YEARS-AMT = YEAR-IN - OLD-YEAR


Back to COBOL General discussion FAQ Index
Back to COBOL General discussion Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close