Inside VESOFT covers tips and techniques you can use with VESOFTs products, especially MPEX.
By Steve Hammond
I cant tell you how many times I have completed an Inside Vesoft column and within days found myself using the exact command or procedure I discussed in the column. It happened just last month when I needed to alter several spool files and used the ALTSPOOLFILE command.
This was slightly different, because I needed to select by a range of dates. I had to dig into the back of the manual to the Appendix to look over some of the date functions. There I realized the vast number of date operators and functions offered in MPEX and its companions. No one really worried about dates until less than 10 years ago when the turn of the millennium was looming, but weve always been able to do any number of functions with dates in MPEX.
We all know that TODAY is a date function - I regularly run:
%YESPURGE LOG####.PUB.SYS(accdate<TODAY-60) to clear all the log files older than 60 days off my system. But you can do a lot more when it comes to calculating and comparing dates. (You can test these commands using the CALC command, so you can check it before deleting an entire account.)
Now that date looks funny. Thats because the date returned is in the YYMMDD format. If I tell it I want to create the date (CDATE) in a month/date/year format, I need to:
Of course, you can do addition and even differences between dates:
Here we see that the difference between June 25th and February 29th of this year is 117 days. Wait a minute - that output is not what we expected! Using CALC, if the result is an integer, it will be displayed in decimal, hexadecimal, octal and ASCII representation of the 4 bytes with periods replacing the junk/unprintable characters.
And whats data manipulation if you cant do boolean?
Of course you can do
the standard greater than, less than, equal to, less than or equal
and greater than or equal.
As you can see BETWEEN is a boolean function, determining if the first date is between the second and the third - and as you can see in this instance, it is not.
If you need to extract certain segments of a date, there are functions - DATEYEAR gives you the two-digit year from a date, DATEYEAR4 extracts the four-digit year, DATEMONTH AND DATEDAY provide the obvious and DATEDAYOFWEEK gives the day of the week:
In the last case, May
26, 2001 fell on a Saturday (1 is Sunday, 2 is Monday, etc.)
Julian date, as defined in most applications, is the number of the day in the year - January 1st is 1, December 31st is 365 or 366 this year. As an aside, in my limited Unix experience, I was struck that it was odd the definition of a Julian date on that system was the number of seconds since some seemingly arbitrary, but no doubt significant date in the past oh well.
The function CDATE is really expanded into three other simpler commands, all involving conversion of dates:
%calc CDATEMDY (87/01/15)
As you can see, it works with or without slashes, on two- or four-digit years and it recognizes valid leap year days. The quotes in there are important I learned the hard way had a job blow up at an inopportune time because I forgot the quotes.
So, MPEX lets you
deal with dates better than my college roommate, but thats a
story for another day.
Copyright The 3000 NewsWire. All rights reserved.