Jump to content
Printz

Determining if a credit card has expired

Recommended Posts

Printz

I am probably asking a very simple question, but could not locate an answer on this forum. I am using FileMaker Pro 8.5.

I have a field named CC1 Exp (the date a credit card expires in a format of 04/10) which is manually entered. What I need to do is, determine if the date entered has expired based on the Current Date, and if so, have the word "Expired" appear in a field next to the CC1 Exp field, or even replace the CC1 Exp text.

Can someone assist me with the script to determine if the card has expired? Thank you for your consideration and assistance.

Share this post


Link to post
Share on other sites
Robert Schaub

You need to convert your field to a date field that includes the last day of the month.

 

So I created a new field called New_Credit_Card_Expiration

 

Here's a script to set the new field your info and the last day of the month.

 

 

Set Field [ Test Table::New_Credit_Card_Expiration; Left(Test Table::Credit_Card_Expiration;3) &

Let ( [ m = If ( IsEmpty ( Left(Test Table::Credit_Card_Expiration;2) ) or Left(Test Table::Credit_Card_Expiration;2)

Credit_Card_Expiration;2) > 12 ;

Month ( Get ( CurrentDate ) ) ; Left(Test Table::Credit_Card_Expiration;2) ) ;

y = If ( IsEmpty (Right(Test Table::Credit_Card_Expiration;2) ) ; Year ( Get ( CurrentDate ) ) ; Right(Test Table::

Credit_Card_Expiration;2)) ] ;

If ( y

// Julian calendar

Case ( m = 2 ; 28 + ( Mod ( y ; 4 ) = 0 ) ; // Julian Calendar leapyear?

m

31 - Mod ( m ; 2 )

) ;

// Gregorian calendar

Day ( Date ( m + 1 ; 1 ; y ) - 1 )

)

)

& Right(Test Table::Credit_Card_Expiration;3) ]

Comment [end of set field]

Commit Records/Requests

If [ Get ( CurrentDate ) > GetAsDate(Test Table::New_Credit_Card_Expiration) ]

Show Custom Dialog [ Message: "CREDIT CARD IS EXPIRED"; Buttons: “OK” ]

End If

 

 

 

Now as you can see in the script I check for an expired CC

 

Note* Original Custom Function by Theo Ros ... I modified it to your needs

 

Not Bad for a substitute sweeper

Share this post


Link to post
Share on other sites
Printz

Thanks Chopper, I appreciate your speedy reply. I messed up when I asked for a script. Actually what I need is a field calculation to do what I was asking. That is, to compare the date entered in the CC1 Exp field (formatted as 04/10) to the current date and enter the word "Expired" in the CC1 Expired field. Sorry for the confusion. Actually an additional question, is there a way within a field, to have the CC1 Exp field display the word "Expired" if the conditions are correct?

Share this post


Link to post
Share on other sites
Robert Schaub

You asked for a script... Look in ScriptMaker.... Set Field has been around since before dirt was discovered.

Share this post


Link to post
Share on other sites
Printz

Chopper, I was changing my previous post as you were asking the question. Hopefully, I explained myself adequately in the updated post. Sorry for the confusion on my part.

Share this post


Link to post
Share on other sites
Robert Schaub

created a new field called New_Credit_Card_Expiration

 

Calc =

 

Left(Test Table::Credit_Card_Expiration;3) &

 

Let ( [ m = If ( IsEmpty (GetAsText( Left(Test Table::Credit_Card_Expiration;2) ) ) or

 

GetAsDate(Month( Left(Test Table::Credit_Card_Expiration;2) ) ) 12 ;

 

Month ( Get ( CurrentDate ) ) ; Left(Test Table::Credit_Card_Expiration;2) ) ;

 

y = If ( IsEmpty (Right(Test Table::Credit_Card_Expiration;2) ) ; Year ( Get ( CurrentDate ) ) ; Right(Test Table::Credit_Card_Expiration;2)) ] ;

 

 

If ( y

 

// Julian calendar

 

Case ( m = "02" ; 28 + ( Mod ( y ; 4 ) = 0 ) ; // Julian Calendar leapyear?

 

m

 

31 - Mod ( m ; 2 )

 

) ;

 

// Gregorian calendar

 

Day ( Date ( m + 1 ; 1 ; y ) - 1 )

 

)

 

)

& Right(Test Table::Credit_Card_Expiration;3)

 

use this new field to compare with the get(currentDate) to see if it is expired

Share this post


Link to post
Share on other sites
Printz

Chopper,

Thanks again for your input. I will give this a try over the weekend. It sure is nice having someone like your self to be so helpful. Thanks again!

Share this post


Link to post
Share on other sites
David Head

Chopper. Why why why why why??? OMG why?

Share this post


Link to post
Share on other sites
Printz

Chopper,

I was talking to my son and he gave me a solution that worked just fine for my purposes. Thank you so much for your input. It was greatly appreciated.

Share this post


Link to post
Share on other sites
This thread is quite old. Please start a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...

Important Information

Terms of Use