- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- SUbtracting in OpenVMS
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
Discussions
Discussions
Forums
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
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
тАО09-20-2010 03:29 AM
тАО09-20-2010 03:29 AM
I am writing a COM to rename a group of files which satisfy the below condition. The File name has the current date and time
Example: 20100919103344
If the difference between the current date (20100920) and the file date (20100919) is greater than 1, then i need to do certain steps.
I tried this but it is not working as expected.
$file_name = "V2B_20100919103344.TXT"
$file_name = "V2B_20100919103344.TXT_TEMP"
$
$SH SYM file_name
FILE_NAME = "V2B_20100919103344.TXT_TEMP"
$file_date = f$extract(4,8,''file_name)
$SH SYM file_date
FILE_DATE = "20100919"
$CUR_DAT = F$CVTIME(,,"DATE") - "-" - "-"
$SH SYM CUR_DAT
CUR_DAT = "20100920"
$
$FINAL = (CUR_DAT - FILE_DATE)
$SH SYM FINAL
FINAL = "20100920"
Please advice.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2010 03:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2010 03:52 AM
тАО09-20-2010 03:52 AM
Re: SUbtracting in OpenVMS
Dan
============================================
$file_name = "V2B_20100919103344.TXT"
$file_name = "V2B_20100919103344.TXT_TEMP"
$!
$SH SYM file_name
$file_date = f$extract(4,8,''file_name)
$SH SYM file_date
$CUR_DAT = F$CVTIME(,,"DATE") - "-" - "-"
$SH SYM CUR_DAT
$!
$ c=f$integer("''cur_dat'")
$ f=f$integer("''file_date'")
$FINAL = (c - f)
$SH SYM FINAL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2010 06:18 AM
тАО09-20-2010 06:18 AM
Re: SUbtracting in OpenVMS
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2010 12:56 PM
тАО09-20-2010 12:56 PM
Re: SUbtracting in OpenVMS
Why subtract? Your requirement
"If the difference between the current date"
_any_ difference will be 1 day or more.
So instead of :
- $FINAL = (CUR_DAT - FILE_DATE)
Use a string compare like:
- $IF CUR_DAT .GTS. FILE_DATE .......
Enjoy,
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2010 02:10 PM
тАО09-20-2010 02:10 PM
Re: SUbtracting in OpenVMS
When DCL sees what appears to be an arithmetic expression containing only "+" and "-" it tries to work out if this is an INTEGER operation or a STRING operation, depending on the apparent types of the operands. In this case CUR_DATE is determined to be STRING, so the operation is STRING. Since the subtrahend is not a substring of the minuend, the result is the minuend.
You need to be very careful with these operators, to make sure DCL understands your intent. Sometimes you need to use F$INTEGER to force an operand to be interpreted as INTEGER or F$STRING to force it to be STRING.
In this case I'd go with Hein and use a comparison. Note that there you also need to be explicit about data type "GTS" for string and "GT" for integer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2010 05:04 PM
тАО09-20-2010 05:04 PM
Re: SUbtracting in OpenVMS
$ yest_date = F$CVTIME("","COMPARISON","DATE") - "-" - "-"
(The above gives 20100921 when I run it because here it's already 21 Sep here.)
Just compare yest_date to the first 8 characters of your filename string.
It's not clear if you want to rename the files but this would be the simplest because you wouldn't need to check if the files were created earlier than yesterday.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2010 06:58 PM
тАО09-20-2010 06:58 PM
Re: SUbtracting in OpenVMS
Thanks a lot for your replies.
I will be trying today with all of your valuable inputs..
Really thanks a lot..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-22-2010 02:02 AM
тАО09-22-2010 02:02 AM
Re: SUbtracting in OpenVMS
I have a problem now.
Consider this Example:
The current date is 20101001(October 1st 2010). The File date is 20100930.
I went with subtracting them as an integer. But i need the value to be 1. If i subtract, it gives the putput as 71.
Please Help..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-22-2010 03:02 AM
тАО09-22-2010 03:02 AM
Re: SUbtracting in OpenVMS
Is there no way you can do this using the f$delta_time lexical.
F$DELTA_TIME
Returns the time difference between a given start and end time.
The end time must be the same as or later than the start time.
Format
F$DELTA_TIME(start-time,end-time)
Times are supplied as "Absolute", so use f$cvtime to convert FILE_DATE back to absolute, Set CUR_DATE to f$cvtime(,"ABSOLUTE","DATE").
f$delta will return the difference as a Delta time. From which you extract the "day" component to test.
It certainly avoids having to worry about days-in-month.
Dave.