Originally Larry Simonsen wrote:
>
> Is there a simple way to calculate the number of days since file
> creation using the finfo and other functions?
And Joseph Rosenblatt replied:
>
> FINFO function -6 returns a date in yyyymmdd format...
Then Paul H. Christidis wrote:
>
> The attached command file, FILEAGE, can do MOST of that. The
> command file has NOT been tested extensively and may not provide
> 100% accuracy for very old files...
So, here's my spin on the solution (same disclaimers as to accuracy!):
:
:HELP CREDAYS
USER DEFINED COMMAND FILE: CREDAYS.XEQ.SYS
PARM FILE_NAME
# CREDAYS.XEQ - DISPLAYS THE NUMBER OF DAYS SINCE FILE WAS CREATED.
# TIM ERICSON 07/14/1998
DAYS !HPYYYY![RHT("0"+"!HPMONTH",2)]![RHT("0"+"!HPDATE",2)]
SETVAR TODAY_DAYS, RETURN_DAYS
DAYS ![FINFO ( "!FILE_NAME", -6 )]
SETVAR CREATED_DAYS, RETURN_DAYS
ECHO
ECHO "!FILE_NAME" WAS CREATED ![TODAY_DAYS - CREATED_DAYS] DAYS AGO.
ECHO
DELETEVAR TODAY_DAYS, CREATED_DAYS, RETURN_DAYS
:
:
:HELP DAYS
USER DEFINED COMMAND FILE: DAYS.XEQ.SYS
PARM D_DATE
# DAYS.XEQ - RETURNS NUMBER OF DAYS SINCE JAN 1, 1900
# D_DATE MUST BE A DATE IN YYYYMMDD FORM.
# TIM ERICSON 07/14/1998
SETVAR D_DAYS, STR ( "!D_DATE", 7, 2 )
SETVAR D_DAYS, !D_DAYS
SETVAR D_MONTH, STR ( "!D_DATE", 5, 2 )
SETVAR D_MONTH, !D_MONTH - 1
SETVAR D_MONTH_DAYS, 0
WHILE D_MONTH > 0 DO
IF D_MONTH = 2 AND ( HPYYYY MOD 4 = 0 )
SETVAR D_MONTH_DAYS, D_MONTH_DAYS + 29
ELSEIF D_MONTH = 2
SETVAR D_MONTH_DAYS, D_MONTH_DAYS + 28
ELSEIF D_MONTH = 4 OR D_MONTH = 6 OR D_MONTH = 9 OR D_MONTH = 11
SETVAR D_MONTH_DAYS, D_MONTH_DAYS + 30
ELSE
SETVAR D_MONTH_DAYS, D_MONTH_DAYS + 31
ENDIF
SETVAR D_MONTH, D_MONTH - 1
ENDWHILE
SETVAR D_YEAR, STR ( "!D_DATE", 1, 4 )
SETVAR D_YEAR_DAYS, ( ( !D_YEAR - 1900 ) * 36525 ) / 100
SETVAR RETURN_DAYS, D_YEAR_DAYS + D_MONTH_DAYS + D_DAYS
DELETEVAR D_@
:
:
NOTE! Change 'CREATED' to 'ACCESSED' and '6' to '7' (in the FINFO
call) and keep it as 'ACCDAYS' for the number of days since last
accessed, and change 'CREATED' to 'MODIFIED' and '6' to '8' and
keep it as 'MODDAYS' for the number of days since the file was
modified!
HTH!
+------------------------------------------------------------------+
My mind is my own, as are my ideas and opinions.
My heart, body, and soul, however, all belong to others. Tim.
+------------------------------------------------------------------+
Tim Ericson tericson DenKor Dental Management Corp.
Sr. Programmer/Analyst at denkor 503-526-4440 (direct number)
(& Systems Manager) dot com http://www.denkor.com
Programming HP3000s since 1983!
+------------------------------------------------------------------+
UDCs and Command Files: http://www.denkor.com/hp3000/command_files
+------------------------------------------------------------------+
|