You might want to simply tell us what you are trying to accomplish.. when I run the code you posted, it returns a number around 3760, which is kind of meaningless to me at first glance.

Let's look at your code:
 Code:
; Get a 4-digit year from @DATE
$yr=left(@date,4)
; get the part of the date where month is on the left and day is on the right
$mn1=right(@date,5)
; now take just the 2 left or 2 right values to get Month number and Day nubmber
$mn=left($mn1,2)
$dy=right($mn1,2)
; that was the hard way - easy way is:
$yr = @YEAR
$mn = @MONTHNO
$dy = @MDAYNO
Keep in mind that the "easy way" has 1 or 2 digit values, while the "hard way" will always have 2 digit strings.. What's odd is that you don't use any of those variables in the part of the script you've shown. Since most macros take no more effort to use than variables, I'd consider replacing any reference to your vars with the macros, unless you need the 2-digit strings. Even then, I'd create the 2-digit string for the month and day with the form
 Code:
$Value = Right('0' + @MONTHNO, 2)
Let's continue..
 Code:
; This takes the value 1, adds the year portion of @DATE as a string..
; starting the formula with a number causes Kix to convert the string
; to a number. The value 1 is then subtracted. Again, the long way to get there..
; $SY = Val(Left(@DATE, 4)) is less obscure, but $SY = @YEAR gets the job
; done directly
$SY = 1 + left(@date,4) - 1

; This converts to a 2-digit year, again wrapping it in a formula to 
; return a number. Just as strange, and can be simplified to
; $SystemYear = Val(Right(@YEAR, 2))
$SystemYear = 1 + right($SY,2) - 1

; more of the same.. simplify to 
;$SystemMonth = @MONTHNO
; and 
;$SystemDay = @MDAYNO
$mn1 = 1 + right(@date,5) - 1
$SystemMonth = 1 + left($mn1,2) - 1
$SystemDay= 1 + right(@date,2) - 1

; Given that today is 2010/03/25, your formula works out to:
; $SystemYear = 10, $SystemMonth = 3, and $SystemDay = 25
; (by whatever method you choose)
; $SystemDays = (10 * 365) + (3 * 30.4167) + 25
; $SystemDays = 3650 + 91.25 + 25, or simply 3766.25
$SystemDays=($SystemYear*365)+($SystemMonth*30.4167)+$SystemDay
Good gosh, is this supposed to be the number of days since 1/1/2000??? If so, the value is off by 30.4167! It is actually the number of days since 1999/12/01.

If this is indeed what you're after, using one of the available UDFs would simplify this greatly. Both TimeConvert and TimeDiff can accomplish this in one line:
 Code:
; Using TimeConvert and specifying the base date as the epoch value:
$SystemDays = TimeConvert(@DATE + ' 00:00:00', '2000/01/01') / 86400
; Since TimeConvert returns a cTime value (seconds of elapsed time) we need to divide by 86400 to get days

; using TimeDiff, specifying the start date, current date, and requesting "days" be returned
$SystemDays = TimeDiff('2000/01/01', 'today', 'D')
The whole "1 + some_string - 1" method is very obscure, not to mention unnecessary. Simplifying the code will make it easier to support.

If you choose to use one of the Time UDFs, make sure you download it and include it in your script. The latest versions of both UDFs are posted in the Kix Library on my web site.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D