problem with short date

R

rjejyork

I am using the short date input mask in my field. But when it shows the
date, it changes the way i want it to look. When entering a date, I want to
be able to simly type 010109 and have it show as 01/01/09. I edited the
input mask to allow this, and it works, but when I tab off the field, it
changes it to 01/01/2009. I want it to stay just as I typed it. I want to
add a "Duplicate record" command but when I try to do it, I get an error with
respect to the date field and I think it is because it is changing the value
from what I typed to showing all four digits of the year and it won't let me
copy the record. Any suggestions?
Thanks
Rachel
 
D

Douglas J. Steele

Sorry, but as long as you're using a Date data type, you really have no
choice here. That's because under the covers, the Date data type is an
eight-byte floating point number, where the integer portion represenst the
date as the number of days relative to 30 Dec, 1899 (and the decimal portion
represents the time as a fraction of a day). In other words, Access must
know the exact year in order to store the date properly.
 
R

rjejyork

Thanks Doug,
Any suggestions on a work around? Also, I am using the date fields to
calculate the number of days between two dates.
 
D

Douglas J. Steele

Why do you want it to display only a two-digit year?

You say you want to add a "Duplicate record" command but you get an error
with it. What's the code you're trying to use?
 
R

rjejyork

The view of the date field isn't as important as the how we can enter the
information. (ex 010109 shows as 01/01/2009 or 01/01/09). But when I add the
command button to duplicate the record, after it copies the record, I get an
error "The value you entered isn't appropriate for the input mask
'99/99/99;0;_' specified for this field."
 
D

Douglas J. Steele

Not sure I can really help you, as I never use input masks. Hopefully
someone else will chime in.
 
J

John W. Vinson

I am using the short date input mask in my field. But when it shows the
date, it changes the way i want it to look. When entering a date, I want to
be able to simly type 010109 and have it show as 01/01/09. I edited the
input mask to allow this, and it works, but when I tab off the field, it
changes it to 01/01/2009. I want it to stay just as I typed it. I want to
add a "Duplicate record" command but when I try to do it, I get an error with
respect to the date field and I think it is because it is changing the value
from what I typed to showing all four digits of the year and it won't let me
copy the record. Any suggestions?
Thanks
Rachel

Change the Format property of the field from "Short date" to "mm/dd/yy".

The format should match the input mask, if you're going to use the input mask
and copy and paste. The value stored in the database isn't changing; a
Date/Time, as Douglas says, is a double float number, not stored in any
particular format. #1/1/09# and #01/01/2009# and #1-Jan-2009# are all stored
as 39814.0000000000.

An alternative to using the input mask is to take advantage of Access' fairly
sophisticated date handling. If you have no input mask (and any format of your
choice) Access will fill in the year for you (using the current year); i.e.
typing 1/7<tab> will fill in 01/07/2009 in four keystrokes. Using the mask you
would need six - 010709.
 
R

rjejyork

Hi John
Thank you. It worked. I simply removed the input mask in the fields and I
can now copy the record without an error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top