Two questions..

You have the DateCalc() UDF in the same script or is it being called?

Also, you would do better to do something like the following:
Code:

$filen='log_dc1'
$filename1 = DIR("\\server\adlogs\"+$filen)
WHILE $filename1 <> "" AND @error = 0
$file = "\\server\adlogs\log_dc1\"+$filen ;comparing the date (if file is 3 days older than todays date, get rid of it)
IF DateCalc(@date,left(getfiletime($file),10)) > 3
? $file "will be deleted"
DEL $file
ENDIF
DIR() ;retrieve next file
LOOP
RETURN



Here is one that I did to remove old Citrix Profiles that were older than 3 days ago
Needs -
DATECALC()
WSHPIPE()
MAILER()
LOGGER()
:
Code:

CLS
BREAK ON
$log=@scriptdir+'\Profileremove.csv'
IF EXIST($log) DEL $log ENDIF
$date=split(@date,'/')[1]+'/'+split(@date,'/')[2]+'/'+split(@date,'/')[0]
$logdata='Run date/time:'+$date+' '+@time+@crlf
$logdata=$logdata+'Days ago,Location,Error Code'+@crlf+'-------------------'
LOGGER($log,$logdata+@crlf)

FOR EACH $i IN Split('01 02 03')
$loc='\\CITRIX'+$i+'\admin$$\profiles\'
$rc=WshPipe('%comspec% /c dir '+$loc+'*.*',1)
FOR EACH $line IN $rc
IF NOT instr($line, 'File Not Found')
;?$line
; -- Convert American Dates to European format
;?$dtchk
$name=split($line)[17]
$dtchk=split(split($line)[0],'/')[2]+'/'+split(split($line)[0],'/')[0]+'/'+split(split($line)[0],'/')[1]
$dt=DATECALC($dtchk,@date)
IF val($dt)>2 AND len($name)>3 AND $name<>'All Users' AND $name<>'DEFAULT'
;?
SHELL '%COMSPEC% /C RD /S /Q '+chr(34)+$loc+'\'+$name+chr(34)
If @error<>$err=1 ELSE $err=0 ENDIF
$logdata=''+$dt+','+$loc+$name+','+$err
LOGGER($log,$logdata+@crlf)
ENDIF
ENDIF
NEXT
NEXT
MAILER('user@@company.com',,,$log)



HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's