---
title: "COBOL Date Logic to Find Number of Days"
description: "Here is COBOL logic you can use for the calculation of DATEs."
url: https://srinimf.com/2016/01/14/cobol-date-logic-to-find-number-of-days/
date: 2016-01-14
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2016/01/twilight-power-lines-evening-evening-sun-46169.jpeg?fit=1880%2C1162&ssl=1
categories: ["COBOL"]
tags: ["COBOL Date to find number of days"]
type: post
lang: en
---

# COBOL Date Logic to Find Number of Days

[You need to](https://srinimf.com/2017/10/18/top-150-payment-processor-entities-listed-to-refer-quickly/) know what date is 150 days from today.  Convert today to an integer date, add 150 to it and convert it back. No more checking which months you’re going through to see if it’s a 30 day or 31 day month. No more leap year calculations. It’s pretty automatic:

01 WS-TODAY PIC 9(8).

Related[SQL EXTRACT Function: How to Get Month, Day, Year](https://srinimf.com/2019/01/28/db2-date-sql-queries-to-use-in-your-current-project/)

01 WS-FUTURE-DATE PIC 9(8).

Related[Quiz on MySQL DATE and TIME Calculations](https://srinimf.com/2024/10/05/quiz-on-mysql-date-and-time-calculations/)

## **Logic to get COBOL future Date**

MOVE FUNCTION CURRENT-DATE (1:8) TO WS-TODAY.

COMPUTE WS-FUTURE-DATE = FUNCTION DATE-OF-INTEGER (FUNCTION INTEGER-OF-DATE (WS-TODAY) + 150)

## **How many days between two dates**

COMPUTE is OK because we’re only using integers here.

COMPUTE WS-DAYS = FUNCTION INTEGER-OF-DATE (WS-DATE-1) – FUNCTION INTEGER-OF-DATE (WS-DATE-2)

Related Posts

- [COBOL INSPECT Useful Logic to Find Spaces in String](https://srinimf.com/2016/06/28/how-to-find-number-of-spaces-in-a-string-using-inspect/)DateJune 28, 2016
- [COBOL Redefines: How to Use Correctly](https://srinimf.com/2015/11/27/cobol-redefines-you-can-override-data-type/)DateNovember 27, 2015
- [Cobol- Date Function (1 of 2)](https://srinimf.com/2011/12/04/cobol-date-function-1/)DateDecember 4, 2011

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2016%2F01%2F14%2Fcobol-date-logic-to-find-number-of-days%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2016%2F01%2Ftwilight-power-lines-evening-evening-sun-46169.jpeg%3Ffit%3D1200%252C742%26ssl%3D1&description=COBOL%20Date%20Logic%20to%20Find%20Number%20of%20Days)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2016/01/14/cobol-date-logic-to-find-number-of-days/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2016/01/14/cobol-date-logic-to-find-number-of-days/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2016/01/14/cobol-date-logic-to-find-number-of-days/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2016/01/14/cobol-date-logic-to-find-number-of-days/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20COBOL%20Date%20Logic%20to%20Find%20Number%20of%20Days&body=https%3A%2F%2Fsrinimf.com%2F2016%2F01%2F14%2Fcobol-date-logic-to-find-number-of-days%2F&share=email)
-

### Like this:

Like Loading…
