Last Comments

Rich Jordan (My Digital Collec…): I never got a tote or lar…
Rich Jordan (My Digital Collec…): I look forward to these. …
Chris (PmWiki): I would say that you prob…
tmr (PmWiki): Has anybody tried to run …
rafael (Print, baby, prin…): Thank you very much. I …
Mark (PmWiki): Yes, that did the trick. …
Chris (PmWiki): Hi Mark, In the apache$…
Mark (PmWiki): Hi, I am also suffering f…
Jose Baars (Burn, baby, burn): Hi, Thanks for writing th…
Aaron (Keeping PAKs): I’ve been working with HP…

Archives

01 Jan - 31 Dec 2006
01 Jan - 31 Dec 2007
01 Jan - 31 Dec 2008
01 Jan - 31 Dec 2009

Reference

dcl.OpenVMS.org
www.OpenVMS.org
OpenVMS FAQ
OpenVMS' official site
OpenVMS documentation
OpenVMS WebRing
Secure Web Server
OpenVMS Hobbyist Forums
Pivot Homepage

Blogs

eight-cubed.com
HoffmannLabs
SYSMGR in the attic
VMS Spoken Here

Miscellany

Powered byPivot - 1.30.2: 'Rippersnapper' 
XML Feed (RSS 1.0) 
XML: Atom Feed 

« My Digital Collection… | Home |

Fun with lexicals

f$delta_time trick

Just a shorty for you.  How do you tell in a command procedure if a file was created today?  I'm talking about a one-liner, with no temporary files, piping, nor jumping hurdles with f$cvtime...

if f$delta_time(f$file("my:file.spec","CDT"),"Tomorrow") .lts. "   1" 

...is true, then it was created today.  If false, then it was created before today. Note there are 3 blank spaces before the "1" in quotes, and you can change that to any number you want (right-justified in a 4 character field).  Want to check if the file was created in the last week? Use "   7".  Last 3 weeks?  "  21" (two spaces).  And so on...

"Tomorrow" translates to midnight, tonight.  "CDT" is the Creation Date and Time of the file.  The delta time will always be a positive value (unless you've got a file created in the future, which Analyze/Disk/Repair should fix for you!)  Using the text string delta time returns, you can actually test to see if a file was created within the past 'delta time', by changing the "Tomorrow" to the null string, "" (i.e., the current time), and change the right side of the comparison to a complete delta time spec (e.g., "   0 12:00:00.00" for within the past 12 hours.)

One final caveat: you'll need OpenVMS v8.x for f$delta_time to understand "Today", "Tomorrow", etc.  This was not supported in 7.3 -- you needed to use f$cvtime to convert the relative descriptors to a valid time spec.  So there is a circumstance where you'd have to jump the f$cvtime hurdle. I'd say "live with it", but you really should upgrade!

Cool, huh?  Well, I think so...



No comments:


No trackbacks:

Please enable javascript to generate a trackback url


  
Remember personal info?

Emoticons / Textile

To prevent automated comment spam, I've got to ask you this innocuous question about the creator of our fav OS, DEC.
 

  ( Register your username / Log in )

Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.