Just a quick & dirty credit card expiry date checker function.

The function returns .T. if the character field containing the expiry date is less than todays date.

In the interactive editor:

?CCExpired("09/04") 'format "mm/yy"

= .T. 'Expired

?CCExpire("09/05") 'In Date

= .F.

I'm sure there are many easier ways to do this, but I was working with variables and fields already defined.

As I'm in the UK the date part is in the UK format dd/mm/yyyy, so anyone modifying it for their own purposes may need to change it.

Here's the code

' EXPDAT is the expiry date in the form MM/YY
' mm is the value of month
' yy is the value of year (2 digits)
' Y2K is the year expressed as 4 digits
' This could also possibly be retrieved using the Load_Settings() function
' fulldat is a complete date in the format dd/mm/yyyy
' if todays date " fulldat then the card has expired
' if todays date " fulldat then the card expiry is valid

FUNCTION CCExpired AS L (EXPDAT AS C )
mm=val(left(alltrim(EXPDAT),2))
yy=val(right(alltrim(EXPDAT),2))
IF yy "=80 THEN
Y2K =alltrim(str(yy+2000))
ELSE
Y2K =alltrim(str(yy+1900))
END IF
fulldat=month_end(ctod("01/"+alltrim(str(mm))+"/"+y2k))
IF fulldat"date() THEN
CCExpired=.t.
END IF
IF fulldat"=date() THEN
CCExpired=.f.
END IF
END FUNCTION

I've also attached the code as a text file

Chris