473,395 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Credit Card Expiration Date format MM/YY

Thank you in advance for any input/assistance. This is driving me crazy. I am storing my expiry date as date/time, format mm/yy, no input mask in my table. I have a form created from it & when I test the field it still shows up as mm/dd/yyyy. I also have the format of the field on the form as mm/yy but still mm/dd/yyyy. What am I missing or doing wrong?

Totally frustrated Kime
Jul 26 '18 #1

✓ answered by zmbd

Kime1266:

If you a table such that:
[t_CreditCardInfor]
[PK] primary key as autonumber
[ExpDate] as date/time data type
[etc]

As NeoPa tried to explain to you - what you are asking doesn't make sense if you are using a date/time data-type.

If you enter a date such as
[t_CreditCardInfor].[ExpDate] = 01/18
expecting access to store that as MM/YY you will be disappointed. MM/YY - isn't a recognized valid date format for the date/time data type - period.

Access will convert the date to USA #01/18/1818# or some other date not MM/YY - there may be some locality applied depending on how you enter the date; however the effect will be the same - something random (if you want proof I'll attach some screen shots).

If you want to actually store the data as "MM/YY" then you will have to set the field to data type "Short Text" and use some magic vba or macro (these are not the same thing) to ensure that only numeric and the "/" are being entered.

Displaying the data as "MM/YY" from a date/time field is trivial - that's the format.

I'd suggest taking the user input and running a before_update event to convert an entry such as "12/18" to the internal date literal #12/01/2018# and store the value as a proper date/time value and using the formatting options of the table, query, or form control to display the information in the desired format.

9 4538
NeoPa
32,556 Expert Mod 16PB
Hi Kime.

You need to understand what storing as a Date/Time means. Separately, that a format is just a format.

Todaye is 26 July 2018 here. Stored as a Date/Time this is a value. Displayed as mm/yy will show simply as 07/18. However - there are many other different dates that also show up as 07/18 when displayed that way. That doesn't mean they're also the same Date/Time value.

If you enter a value such as July 2018, or any valid variant of the same month, you will typically have a Date/Time returned that's the first day of that month - so, 1st July 2018. This can be displayed many ways but only when displayed as mm/yy will it show as 07/18.

I'm a little confused about what you describe as a field on your Form as Forms, while they have a Fields collection, only show those Fields via Controls. I would guess you're talking about a TextBox Control. I'd be interested to see a TextBox control that showed a Date/Time value as anything but mm/yy if it's been correctly set as having that format.
Jul 26 '18 #2
Thank you for your response, NeoPa. This was my first time posting so I may have been unclear. I have a field that I want the data to be stored/displayed in mm/yy format. I have the format property in the table as mm/yy and tried it with & without an input mask but when I enter test data in the field, it is returning a results exactly as you stated, in mm/dd/yyyy. Is there a way to have it display & store as I want?
Jul 27 '18 #3
zmbd
5,501 Expert Mod 4TB
Kime1266:

If you a table such that:
[t_CreditCardInfor]
[PK] primary key as autonumber
[ExpDate] as date/time data type
[etc]

As NeoPa tried to explain to you - what you are asking doesn't make sense if you are using a date/time data-type.

If you enter a date such as
[t_CreditCardInfor].[ExpDate] = 01/18
expecting access to store that as MM/YY you will be disappointed. MM/YY - isn't a recognized valid date format for the date/time data type - period.

Access will convert the date to USA #01/18/1818# or some other date not MM/YY - there may be some locality applied depending on how you enter the date; however the effect will be the same - something random (if you want proof I'll attach some screen shots).

If you want to actually store the data as "MM/YY" then you will have to set the field to data type "Short Text" and use some magic vba or macro (these are not the same thing) to ensure that only numeric and the "/" are being entered.

Displaying the data as "MM/YY" from a date/time field is trivial - that's the format.

I'd suggest taking the user input and running a before_update event to convert an entry such as "12/18" to the internal date literal #12/01/2018# and store the value as a proper date/time value and using the formatting options of the table, query, or form control to display the information in the desired format.
Jul 27 '18 #4
That concept worked. Thank you so much.
Jul 27 '18 #5
NeoPa
32,556 Expert Mod 16PB
ZMBD:
Access will convert the date to USA #01/18/1818# or some other date not MM/YY
To be technically accurate Access converts the input into a Date/Time value. Such a value doesn't have any format. It is a storage thing rather than a display thing.

Many people struggle to understand the difference and get all caught up because they assume one is the same as the other. I don't like to get into the nitty-gritty of Date/Time storage too much because it should be irrelevant how any particular engine chooses to handle things internally, but for Access it basically stores all dates as a signed floating-point value reflecting the number of days (including fractions thereof) since 30th December 1899. The possible formats for Date/Times are numerous - but irrelevant to how the data is stored. Without any format Now() (27/07/2018 15:37:08) would simply show as 43308.650787037, which gives a clearer understanding of the difference between Date/Time values and formatted Date/Time strings.

PS. Well done for explaining the situation as well as you did. The OP seems to have grasped at least some of the issue.
PPS. I'm sure you already understood everything exactly - just let slip a little in the explanation thereof ;-) I didn't mean to sound critical at all. Just very fussy about details.
Jul 27 '18 #6
zmbd
5,501 Expert Mod 4TB
To be technically accurate Access converts the input into a Date/Time value. Such a value doesn't have any format. It is a storage thing rather than a display thing.
NeoPa,

You are absolutely correct -
In my defense ( :) ) I was trying to simplify the explanation by using the date literal (#DD/MM/YYYY#). I also wanted to point out that internally Access will tend interpret dates in the USA format (how many times has this tripped up a VBA script or a simple query?!)... unfortunately, we can't easily convert in our heads (27/07/2018 15:37:08) ==> #7/24/2018 15:37:08# ==> even though in the field it's actually stored as 43308.650787037

Would be nice if humans had a watch to tell time in the decimal format - then we'd argue about what start date we should use... Jan 1, 1900 or Dec 31, 1899 (Lotus eat your heart out)
Jul 27 '18 #7
NeoPa
32,556 Expert Mod 16PB
Zmbd:
then we'd argue about what start date we should use... Jan 1, 1900 or Dec 31, 1899 (Lotus eat your heart out)
For reasons I've never really understood Access uses Dec 30 1899 (as per my post #6). Go figure.
Expand|Select|Wrap|Line Numbers
  1. ?Format(0,"d/m/yyyy");
  2. 30/12/1899
Jul 28 '18 #8
How interesting. I was unaware that Access used Dec 30 1899. I thought ALL programs used 1/1/1900 as day 1. Thanks so much as I was able to get it to work using text as a result of both responses and learned a thing or two. On to my next posting question...
Aug 3 '18 #9
NeoPa
32,556 Expert Mod 16PB
Coincidentally, and not by my looking but a good friend just explained it elsewhere out of the blue, I recently learned why Access uses 30th December 1899, rather than 31st December 1899, as day 0.

It turns out that Lotus 123, which many of you will remember as the de-facto leader in spreadsheet software before MS came along with Excel and eventually blew it out of the water, had an error in its date logic whereby it treated February 1900 as having 29 days instead of 28 (Divisble by 4; divisible by 100; not divisible by 400). This same error was propagated by Excel as, at the time, it was important for it to behave like the market leader so it could claim compatibility and encourage users to switch without strange problems. Thus it is that even now, if you show Format(60,"d mmm yyyy") you'll see 29 Feb 1900.

It is because of this that the base date, which should have been 31 Dec 1899, turned into 30 Dec 1899. Who'd 'a' thunk?
Aug 4 '18 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: sam1967 | last post by:
I know how to build forms with ASP and process user input. Now i want to take credit card payments via a form. i will then download the details and process them via our credit card machine. do...
6
by: Simon Wigzell | last post by:
My client wants to have credit card information fields on his forms for his website visitors to be able to buy his wervices by credit card. The credit card info - Brand, number and expiry date will...
1
by: Lecture Snoddddgrass | last post by:
Hi, I'm designing an application in which the user will enter a credit card number and expiration date. I want my application to check with the credit card company to get authorization for...
10
by: dries | last post by:
A friend of mine has a problem with his credit card validation routine and it is probably a simple thing to solve but I cannot find it. It has to do with the expiry dates. What happens is that as...
0
by: Rock | last post by:
Hi,all: I have find a example to set expiration date of word permission object, but it was using VBA code. Dim objUserPerm As Office.UserPermission Set objUserPerm =...
4
by: Michelle A. | last post by:
I have a form that takes in a credit card number, just a series of numbers 1234123412341234. When they get to the "Review" page and display all the information a user has entered, I would like the...
3
by: Dani | last post by:
We currently have an online form that customers fill out to buy one of our products. After they submit it, it sends them an email containing all the order information including the credit card #. ...
1
by: Anatoly Kurilin | last post by:
Hi, I need to enter date into a control without a month day - just mm/yyyy. I tried to use format mm/yyyy. It displays date OK, but when I edit, it shows dd/mm/yyyy. What's the corret way o doing...
3
by: xian2 | last post by:
Hi, I am trying to validate a credit card expiry date so it is no later than three years ahead of today's date. I am OK with the validation as far as Date()+1096 which is the maximum number of days...
1
by: securedcardss | last post by:
http://card.2youtop.info secured credit card card credit instant secured card cash credit secured card
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.