- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Converting COMPARISON to ABSOLUTE time
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 05:28 AM
08-08-2007 05:28 AM
I often store COMPARISON times in records so that I can, well, compare times. Now, I'd like be able to use some the F$CVTIME options to get WEEKDAY, etc, but don't see an easy way to convert the time back to ABSOLUTE, which F$CVTIME seems to require. (Also - I noticed that the F$DELTA lexical only uses ABSOLUTE times).
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 06:11 AM
08-08-2007 06:11 AM
Re: Converting COMPARISON to ABSOLUTE time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 06:24 AM
08-08-2007 06:24 AM
Re: Converting COMPARISON to ABSOLUTE time
use. Dean
**********
$!
$! whatday.com dean mcgorrill 08-mar-2007
$!
$! return weekday and time, pass a date via p1 parameter
$!
$ wo=="write sys$output"
$ daytime = f$cvtime(p1,,"weekday") + " " + -
f$cvtime(p1,"absolute","datetime")
$ daytime = f$extract(0,f$locate(".",daytime),daytime)
$ wo daytime
$ exit 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 06:57 AM
08-08-2007 06:57 AM
Re: Converting COMPARISON to ABSOLUTE time
Interesting. This seems to be an error in the documentation that was fixed sometime between Version 6.2 and Version 8.2 (I do not have the time to narrow it further).
Off the top of my head, given the fact that F$CVTIME does not do it directly, I would engage in a little slight of hand. F$CVTIME is still known to work for DELTA and combination times. I would use F$ELEMENT to extract the year, insert it into a January 1, xxxx absolute date and use the rest of the comparison date to create a delta time, using F$CVTIME to then get the various components.
If I am not being clear, please let me know.
- Bob Gezelter, http://www.rlgsc.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 07:46 AM
08-08-2007 07:46 AM
SolutionYou are not missing anything, there is no lexical function to convert from ABSOLUTE format to DELTA format (at least not that I am aware of).
It can be done in one line of DCL, although it isn't pretty. Because the COMPARISON format is well defined, we can extract the year, and day without a problem, the trick is to convert the numerical month to the three character month name abreviation. The easiest way to do that is with the f$element function.
Here's the an example converting a comparision time in the symbol ct to an absolute time in symbol at.
Note: it does not handle DELTA times.
$ ct=f$cvtime("")
$ sho sym ct
CT = "2007-08-08 15:12:09.25"
$ at=f$extract(8,2,ct)+"-"+f$element(f$extract(5,2,ct),",",",JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC")+"-"+f$extract(0,4,ct)+f$extract(10,12,ct)
$ sho sym at
AT = "08-AUG-2007 15:12:09.25"
It would be nice to have an F$CVCOMPARISON_TIME or F$CVCTIME function with an optional "DCL" qualifier to place a ":" between the date and time.
Here's a more understandable version (not tested, just typed in)
$ dd = f$extract(8,2,ct)
$ mm = f$extract(5,2,ct)
$ mmm = f$element(mm,"|","|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC")
$ yyyy = f$extract(0,4,ct)
$ time = f$extract(11,11,ct)
$ at = dd + "-" + mmm + "-" + yyyy + " " + time
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 07:49 AM
08-08-2007 07:49 AM
Re: Converting COMPARISON to ABSOLUTE time
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 08:42 AM
08-08-2007 08:42 AM
Re: Converting COMPARISON to ABSOLUTE time
$ CT = "2007-01-01 15:12:09.25"
$ x = 31*f$extr(5,2,ct)-31
$ write sys$output f$extr(8,2,CT)+"-"+f$elem(1,"-",f$cvtime("1-JAN +''x'-","ABSOLUTE"))+"-"+f$extr(0,4,ct)+f$ext(10,99,ct)
01-JAN-2007 15:12:09.25
$ CT = "2007-12-31 15:12:09.25"
$ x = 31*f$extr(5,2,ct)-31
$ write sys$output f$extr(8,2,CT)+"-"+f$elem(1,"-",f$cvtime("1-JAN +''x'-","ABSOLUTE"))+"-"+f$extr(0,4,ct)
31-DEC-2007
The helper variable 'x' is a number of days since the start of the year garantueed to be in te right month, but an slowly increasing day in each month.
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 09:01 AM
08-08-2007 09:01 AM
Re: Converting COMPARISON to ABSOLUTE time
You've confirmed what I found, and have given me some ideas.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 09:14 AM
08-08-2007 09:14 AM
Re: Converting COMPARISON to ABSOLUTE time
Specifcally, it would be nice if the following was allowed and worked.
$ AT = lib$cvtime("2007-01-02 17:59:59.27","ABSOLUTE",,"COMPARISON") ! not implemented
$ show symbol at
AT = "02-JAN-2007 17:59:59.27" ! this is just a wishlist
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 09:38 AM
08-08-2007 09:38 AM
Re: Converting COMPARISON to ABSOLUTE time
I agree with your suggested addition, but I'd also like F$CVTIME and F$DELTA to accept any time format as input!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 10:37 AM
08-08-2007 10:37 AM
Re: Converting COMPARISON to ABSOLUTE time
Can you provide some examples of what you would expect to work, with input and output? "any time format as input" is a bit ambiguous.
Jon
P.S. Does anyone know if there is anything like the old DECUS SIR (System Improvement Request) still around? I have seen references to "Advocacy" but don't know where it is or if it is still active.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 11:13 AM
08-08-2007 11:13 AM
Re: Converting COMPARISON to ABSOLUTE time
The only price to pay for that convention would be the inability to default to the current year. For example, 20 august could not be: "-08-20" because this already means today minus 8 days and 20 hours.
Maybe 0000- or 0- can be used to express 'current year'.
A nice benefit of the comparison time is that it is language independend. (btw... the 'JAN' I hardcoded in my earlier example works in a good many western languages)
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2007 12:22 PM
08-08-2007 12:22 PM
Re: Converting COMPARISON to ABSOLUTE time
OpenVMS already has a fairly general mechanism for dealing with the multitude of possible date/time formats using the LIB$ date/time formatting routines. See LIB$INIT_DATE_TIME_CONTEXT and friends for details.
It's effectively a $FAO like format control string to define the position and format of various components of date and time values. See the default absolute time format:
$ SHOW LOGICAL/TABLE=*DT*
(LNM$DT_FORMAT_TABLE)
"LIB$DATE_FORMAT_001" = "!DB-!MAAU-!Y4"
"LIB$TIME_FORMAT_001" = "!H04:!M0:!S0.!C2"
Using this mechanism, a generic date conversion lexical function would accept an input date/time string and format string, and an output format string:
output=F$FORMAT_DATE(date_in [,[in_format] [,[out_format]]])
Converting from comparison format to absolute format would therefore be:
$ abs=F$FORMAT_TIME(comp,-
"!Y4-!MM-!DD !H04:!M0:!S0.!C2",-
"!DB-!MAAU-!Y4 !H04:!M0:!S0.!C2")
or, since a missing format string would use the system default, the second format string could be omitted. I'd also expect to be able to specify a logical name as the format string.
I don't know if HP has a working method for users to request enhancements. I'd guess that logging a case against a service contract and asking the engineer to submit a formal request to engineering would be the most likely to succeed.