OK. I'm reposting the corrected version which does not have the inconsistencies of the other version.

code:
BREAK ON
CLS

IF Left(@kix,1) < 4
?"This script requires Kixtart 4.x"
SLEEP 2
EXIT
ELSE
$ldomain = @domain
$lstrusername = "servicesql"
$mailhost = "smtp.server.com"
$adminrecpt = "recipient@@server.com"
$userobj = GetObject("WinNT://$LDomain/$lstrUserName")
$pwexpire = $userobj.passwordexpirationdate

?"UserAuthor: " + $userobj.name
?"UserPasswordExpires: " + $pwexpire

$tt = SPLIT($pwexpire," ")
$mdy = SPLIT($tt[0],"/")
$expiredatearray = $mdy[2],$mdy[0],$mdy[1]
$currentdatearray = "@YEAR","@MONTHNO","@MDAYNO"


Function CalcDayofYear($ymdarray) ; Only works on non-millenium years after 2000.
$Calendar = 31,28,31,30,31,30,31,31,30,31,30,31
If VAL($ymdarray[0]) & 1 $Ly = 0 ; leap year calculations
Else
If (Val($ymdarray[0])/2) & 1 $Ly = 0
Else $Ly = 1
Endif
Endif
$calendar[1] = $calendar[1] + $LY
$mdays = 0
For $m = 0 to (Val($ymdarray[1]) -2)
$mdays = $mdays + $calendar[$m]
Next
$CalcDayofYear = $mdays + $ymdarray[2]
EndFunction

$diffyears = VAL($expiredatearray[0]) - VAL($currentdatearray[0])
If $diffyears > 0
$YearstoDays = 0
For $countyear = VAL($currentdatearray[0]) to (VAL($expiredatearray[0])-1)
$acountyear = $countyear,"12","31"
$YearstoDays = $Yearstodays + CalcDayofYear($acountyear)
Next
Endif

$daystoexpire = CalcDayofYear($expiredatearray) - CalcDayofYear($currentDateArray) + $yearstodays
If $daystoexpire <= 2
? "Password Change required within 2 days, please change"
SHELL 'postie.exe -host:$MailHost -to:$AdminRecpt -from:"ServiceAccountChg" -s:"Password Change" -msg:"The service account: $lstrUserName needs to be changed."'
ELSE
? "Password will not expire for more than 2 Days, no action is needed"
ENDIF

ENDIF

I fixed the problem with the next year/leap year stuff. Still won't work with the year 2100 (who cares?)

Brian

[ 04 June 2002, 17:16: Message edited by: BrianTX ]