I just couldn't let it lie...
I think this one is 100% accurate - including the calculation of number of days since 1997-01-01...
CODE
// extract parts from %last_played%, as per wiki suggestion
$puts(last_played_year,$substr(%last_played%,1,4))
$puts(last_played_month,$substr(%last_played%,6,7))
$puts(last_played_day,$substr(%last_played%,9,10))
$puts(last_played_hour,$substr(%last_played%,12,13))
$puts(last_played_min,$substr(%last_played%,15,16))
$puts(last_played_sec,$substr(%last_played%,18,19))
// find number of days since 1997-01-01
$puts(dy,$sub(%_system_year%,1997))
$puts(is_leap,$ifgreater($mod(%_system_year%,4),0,,1))
$puts(system_totaldays,$add($mul($get(dy),365),
$div($get(dy),4),
$select(%_system_month%,0,31,59,90,120,151,181,212,243,273,304,334),
$if($and($get(is_leap),$greater(%_system_month%,2)),1,0),
$sub(%_system_day%,1)))
// find number of days difference between last_played and 1997-01-01
$puts(dy,$sub($get(last_played_year),1997))
$puts(is_leap,$ifgreater($mod($get(last_played_year),4),0,,1))
$puts(last_played_totaldays,$add($mul($get(dy),365),
$div($get(dy),4),
$select($get(last_played_month),0,31,59,90,120,151,181,212,243,273,304,334),
$if($and($get(is_leap),$greater($get(last_played_month),2)),1,0),
$sub($get(last_played_day),1)))
// record the difference between both values in last_played_numdays
$puts(last_played_numdays,$sub($get(system_totaldays),$get(last_played_totaldays)))
// report last_played_numdays
$get(last_played_numdays)
I've tested this against VB's DateDiff() function and it all tallies.
Edit: And here's my test script:
CODE
$puts(system_year,2007)
$puts(system_month,11)
$puts(system_day,24)
// find approximate number of days since 1997-01-01
$puts(dy,$sub($get(system_year),1997))
$puts(is_leap,$ifgreater($mod($get(system_year),4),0,,1))
$puts(system_totaldays,$add($mul($get(dy),365),
$div($get(dy),4),
$select($get(system_month),0,31,59,90,120,151,181,212,243,273,304,334),
$if($and($get(is_leap),$greater($get(system_month),2)),1,0),
$sub($get(system_day),1)))
$get(system_totaldays)