Problem with date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table that has a date field, the properties are set to short date
and the input mask is set to 99/99/99;; however when I enter data in the
form, the date changes to the date and time ie if today is 05/23/04 it will
display 05/23/05 08:30:30 AM, how do get rid of that time....

Please help!
 
Don't use a date field use a string field if you really must not store the
time, or just disregard the time element when showing on a form e.g. set the
format of the textbox on a form to short date, the underlying field will
still have the time you just cannot see it.
 
Alex White MCDBA MCSE said:
Don't use a date field use a string field if you really must not
store the time, or just disregard the time element when showing on a
form e.g. set the format of the textbox on a form to short date, the
underlying field will still have the time you just cannot see it.

I would not recommend using a text field if a date is to be stored.
That leads to to many possible issues when dates are to be compared or
formatted for different regional settings. I say, if you're storing a
date, use a date/time field. If the date should have no time component,
takes steps at entry time to ensure no time is entered. True, the time
component still really exists internally, but since it's always 0
(midnight) you can ignore it.

There must be something the OP isn't telling us about the way these
dates are being entered on the form, since I see nothing in the post
that would explain where the time is coming from.
 
JOM said:
I have a table that has a date field, the properties are set to short
date and the input mask is set to 99/99/99;; however when I enter
data in the form, the date changes to the date and time ie if today
is 05/23/04 it will display 05/23/05 08:30:30 AM, how do get rid of
that time....

Please help!

I don't see where the time is getting into the field. Are you saying
that, on the form, you enter a date in accordance with the input mask,
for example 05/23/04, and it automatically adds the time? Something odd
is going on. Is there code behind the form -- in this control's event,
or in some event for the form or even some other control, that modifies
this field?

In the table design, what are these properties of the field:

Field Name
Data Type
Format
Input Mask
Default Value

?

On the form, what are these properties of the control that is -- or
should be -- bound to that field:

Name
Control Source
Format
Input Mask
Default Value

?
 
ok in the table design this is what is there
Field Name---Dates
Data Type----date/time
Format ------short date
Input Mask---99/99/00;;_
Default Value--=date()
Name---------Dates
Control Source---Dates
Format------------Short date
Input Mask--------99/99/00;;
Default Value-------"blank"
 
JOM said:
ok in the table design this is what is there
Field Name---Dates

I take that last item means that the Default Value property of the
control is blank -- not the literal string "blank"?

I don't see any way that these properties are going to translate a
manual entry of 05/23/05 to a stored value of #05/23/05 8:35 AM#. Are
you saying that it does that? Or does the time only appear as the
default value, before/unless you actually enter a date in the field?

If the time shows up only in the default value, what happens if you
clear the Default Value property in the field design?

Is there, in fact, any code behind the form that modifies this field?
 
I am confused with the question. When I set up a mask for a date I used
"mm/dd/yyyy" for Y2K compliance. A microsoft date is always a time and a
date stamp. "12/31/2005" is simply an integer without a decimal point. Time
is expressed as a decimal .50 would be noon. Sometimes I use
Format(Now(),"mm/dd/yyyy") to populate a standard date without time. Often
I'll use an after update event to make sure that we have a pure date. Since
the time in Access is a number Lng((Now()) trims off the time and gives you a
pure date.

I think when you use "99/99/99" you are setting yourself up for problems.
That mask would accept any number 0-9 in any of the fields. So 13/33/99 would
be ok. While "mm/dd/yyyy" will recognize 13 and an invalid month, 33 as an
invalid date, and 99 as ambiguous "1999 to 9999."

Forgive me if i've missed the point.
 
SacCourt said:
I am confused with the question. When I set up a mask for a date I
used "mm/dd/yyyy" for Y2K compliance. A microsoft date is always a
time and a date stamp. "12/31/2005" is simply an integer without a
decimal point. Time is expressed as a decimal .50 would be noon.
Sometimes I use Format(Now(),"mm/dd/yyyy") to populate a standard
date without time. Often I'll use an after update event to make sure
that we have a pure date. Since the time in Access is a number
Lng((Now()) trims off the time and gives you a pure date.

The Date() function gives you a "pure" date without having to strip off
the decimal, "time", portion. You can also use the DateValue() function
to strip the time from a date+time value.
I think when you use "99/99/99" you are setting yourself up for
problems. That mask would accept any number 0-9 in any of the fields.
So 13/33/99 would be ok. While "mm/dd/yyyy" will recognize 13 and an
invalid month, 33 as an invalid date, and 99 as ambiguous "1999 to
9999."

I agree that input masks for dates tend to be counterproductive. It
doesn't explain where the time is coming from in this case, though.
 
Beware that InputMask and Format Property are 2 different properties.
InputMask controls how data should be entered and Format controls how data
is to be display.

I think you might have got confused between the 2 properties in your
statement:

'...When I set up a mask for a date I used "mm/dd/yyyy" for Y2K compliance
....'

since "mm/dd/yyyy" is not a valid InputMask.

Check Access Help on InputMask and Format Property.

HTH
Van T. Dinh
MVP (Access)
 

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

Back
Top