Good day all.
I am trying to determine the last day of each month programmatically and this is the best I can come up with.
Thanks to Rob van der Woude for the leap year bit.
I have RTFM and searched here, but no luck.
So I took a stab at it.
Please be gentle.
Code:
;Last day of each month
$a = "31","28","31","30","31","30","31","31","30","31","30","31"
; Initialize
$LeapYear = 0
; A leap year is any multiple of 4...
$Test = $Year / 4
$Test = $Test * 4
If $Year = $Test
$LeapYear = 1
EndIf
; ...except If it is a multiple of 100...
$Test = $Year / 100
$Test = $Test * 100
If $Year = $Test
$LeapYear = 0
EndIf
; ...unless it is a multiple of 400!
$Test = $Year / 400
$Test = $Test * 400
If $Year = $Test
$LeapYear = 1
EndIf
;Reset the value in the array
If $LeapYear = 1
$a[1] = 29
EndIf
;Last day of the current month
$ld = $a[@MONTHNO - 1]
_________________________
Taxation WITH representation isn't so hot, either!