View previous topic :: View next topic
|
Author |
Message |
SlippingJimmy
New User
Joined: 21 Sep 2022 Posts: 10 Location: USA
|
|
|
|
I am receiving two dates from JCL, and I need to find out how many days are between the two. I've read this but I am not sure it applies to what I need to do.
I've tried converting the date to FIXED BIN 31 after receiving the params and tried this below but when I go from 1 Jan to 1 Feb it gives 100 when it should be 31
Code: |
dcl total1 fixed bin(31);
total1 = enddate - startdate;
|
I am not sure of the best way to get the number of days between the two dates. Any advice?[/code] |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
I am receiving two dates from JCL, and I need to find out how many days are between the two |
What format are the two dates in? One method would be to separate the years and month/day, convert the month/day to Julian day, do the subtraction of the Julian days, and adjust if different years are involved.
Which, considering this is a forum for professionals, is WAY more information than you should need to resolve the problem. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1314 Location: Vilnius, Lithuania
|
|
|
|
RTFM!
There are a sjitload of builtin functions in Enterprise PL/I that deal with dates! |
|
Back to top |
|
|
SlippingJimmy
New User
Joined: 21 Sep 2022 Posts: 10 Location: USA
|
|
|
|
Robert Sample wrote: |
What format are the two dates in? |
the format is YYYYMMDD
Robert Sample wrote: |
Which, considering this is a forum for professionals, is WAY more information than you should need to resolve the problem. |
I have searched the forum and read the docs. Some of the information is dated and doesn't work. One, in particular, was from 2013 that seemed promising but didn't work
When I ask, it's not because I didn't research. |
|
Back to top |
|
|
SlippingJimmy
New User
Joined: 21 Sep 2022 Posts: 10 Location: USA
|
|
|
|
What is the meaning of this?
prino wrote: |
There are a sjitload of builtin functions in Enterprise PL/I that deal with dates! |
True, but none of them give the number of days between the two dates like in COBOL. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1314 Location: Vilnius, Lithuania
|
|
|
|
SlippingJimmy wrote: |
I have searched the forum and read the docs. Some of the information is dated and doesn't work. One, in particular, was from 2013 that seemed promising but didn't work
When I ask, it's not because I didn't research. |
"Some of the information is dated…"
We're now in 2022, maybe you should go to the IBM site and look at the PL/I Language Reference for the release of Enterprise PL/I you're now using!
These are, just Cut & Paste from the Enterprise PL/I V6.1 manual, the current date and time processing builtins:
Code: |
Table 64. Date/time built-in functions
Function Description
DATE Returns the current date in the pattern YYMMDD.
DATETIME Returns the current date and time in the user-specified pattern or in the default pattern YYYYMMDDHHMISS999.
DAYS Returns the number of days corresponding to a date/time pattern string, or the number of days for today's date.
DAYSTODATE Converts a number of days to a date/time pattern string.
DAYSTOMICROSECS Converts a number of days to a number of microseconds.
DAYSTOSECS Converts a number of days to a number of seconds.
JULIANTOSMF Converts a date from Julian format to SMF format.
MAXDATE Returns the latest date/time value for a specified date/time pattern.
MICROSECS Returns the number of microseconds corresponding to a date/time pattern string, or the number of microseconds for today's date.
MICROSECSTODATE Converts a number of microseconds to a date/time pattern string.
MICROSECSTODAYS Converts a number of microseconds to a number of days.
MINDATE Returns the earliest date/time value for a specified date/time pattern.
REPATTERN Takes a value holding a date in one pattern and returns that value converted to a date in a second pattern.
SECS Returns the number of seconds corresponding to a date/time pattern string, or the number of seconds for today's date.
SECSTODATE Converts a number of seconds to a date/time pattern string.
SECSTODAYS Converts a number of seconds to a number of days.
SMFTOJULIAN Converts a date from SMF format to Julian format.
STCKETODATE Converts a STCKE value to a date/time pattern string.
STCKTODATE Converts a STCK value to a date/time pattern string.
TIME Returns the current time in the pattern HHMISS999.
TIMESTAMP Returns the current time in the pattern YYYY-MM-DDHH.MI.SS.999999.
UTCDATETIME Returns the current Coordinated Universal Time (UTC) in the pattern YYYYMMDDHHMISS999.
UTCMICROSECS Returns the number of microseconds corresponding to the current UTC time.
UTCSECS Returns the current Coordinated Universal Time (UTC) in the Lilian format in seconds.
VALIDDATE Indicates if a string holds a valid date.
WEEKDAY Returns the day of the week corresponding to the current day or specified DAYS value.
Y4DATE Takes a date value with the pattern 'YYMMDD' and returns the date value with the two-digit year widened to a four-digit year.
Y4JULIAN Takes a date value with the pattern 'YYDDD' and returns the date value with the two-digit year widened to a four-digit year.
Y4YEAR Takes a date value with the pattern 'YY' and returns the date value with the two-digit year widened to a four-digit year. |
|
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1049 Location: Richmond, Virginia
|
|
|
|
SlippingJimmy -
If you are concerned that the responders have perhaps seemed less than helpful, look at your original post:
Code: |
dcl total1 fixed bin(31);
total1 = enddate - startdate;
|
You do not show:
1. how you assigned values to your variables
2. what their values are before the code
3. what total1 equals after the assignment statement
PL/I has especially neat statements, GET DATA and PUT DATA, that make it SO easy to intersperse display of intermediate values.
In complicated programs, I used to keep PUT DATA statements scattered at important places in production programs and control their execution by a GET DATA input parameter. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
unfortunately the original post shows a poor understanding of date arithmetics
the only way to get 100 as told is to just use a plain subtraction of two dates in the format YYYYMMDD
20220201 - 20220101 ==> 100
|
|
Back to top |
|
|
|