Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I store a credit card's expiration date if it only consists of the month and year?

Tags:

date

mysql

How do I store a credit card's expiration date if it only consists of the month and year?

The date field in mysql accepts the following format: yyyy-mm-dd. An expiration date without a day is not invalid using that format.

Do I use varchar, instead? And does that not prevent me from making calculations to determine when cards expire and what not?

like image 494
Mohamad Avatar asked Apr 17 '11 19:04

Mohamad


People also ask

Does card expiry date include the month?

Expiration dates appear on the front or back of a credit card in a two-digit month/year format. Credit cards expire at the end of the month written on the card. For example, a credit card's expiration date may read as 11/24, which means the card is active through the last day of November 2024.

Is credit card expiration date end of month?

Is it good through the end of the month? All U.S. Bank credit and debit cards are valid through the last day of the month listed on the card. For example, if you have an expiration of 05/19 (May 2022) listed on the card, it's good until May 31, 2022.

How do expiration dates work on credit cards?

A credit card expiration date is a set time when a card will need to be replaced. Typically, the expiration date is represented as a numerical month and a year. For example, an expiration date of 07/25 means the card will expire on July 31st, 2025, depending on the issuer.

What does yyyy mean on credit card?

In short, all financial transaction cards should show the card's expiration date in one of the following two formats: “MM / YY” or “MM-YY” — with the first being the by far most common for credit cards. This represents two digits for the month and two for the year — for example, “02 / 24”.


1 Answers

You could always just use the LAST_DAY function to insert the last day of the month.

For example:

SELECT LAST_DAY('2011-02-01')

Would result in 2011-02-28 this year. In general, you want the last day of the month for a credit card because that's the actual last day it's valid.

like image 153
pickypg Avatar answered Nov 06 '22 04:11

pickypg