View Full Version : Access Date error?

07-16-2002, 09:01 PM
Now, I don't know what happened, but when I added the date to the database at one point (June 9-12 is what was recorded before it wasn't used again) it mixed up the day and month, so instead of 6/9/2002 it was 9/6/2002, and therfore messed up my db.

All the did to add the date in the db was use Now(), I fixed my problem by using:

StrWhen = Month(Now()) & "/" & Day(Now()) & "/" & Year(Now()) & " " & FormatDateTime(Now(), vbLongTime)

It recorded in the db and i had no problem, but I can't really test my problem to see if it happens again. It must be some kind of random error.

I have try to turn my data to something like december 6 2002 or june 1 2002. It doesn't have a problem with them at all.

Anyone else have this problem? or know why it might do that at all? Have you fixed the problem in a better and tested way, other then mine?

07-17-2002, 03:19 AM
Why don't you just insert it with Date() ? By default it's MM/DD/YYYY.

Or, I haven't tried this with Access (but there is likely a way to do it, if it's not exactly the same), but in SQL Server you can have the database automatically write the date field for you whenever a record is inserted... just change the default aspects of the databse field. This is really handy!

07-17-2002, 08:34 AM
I wouldn't know how to do that... it's not like autonumnber and just a selection i would pick...
is it?

If there is a way with access i would love to know... it would help alot...

Now() and Date() are the same thing... aren't they?
I know that they give the same result

Now() is MM/DD/YYYY because it works for other dates and some time even the dates that gave me a problem before.

I added my new code (shown above) first because I thought I was getting the date from certain computers set up at DD/MM/YYYY and not MM/DD/YYYY, but it is SERVER SIDE. But I think the way I put it, will not give me a problem... seeing how i am being exact with my numbers. :)
What do you think?

Whammy, do you use Access or SQL?

If SQL, would I be able to use IIS with SQL and not have to install anything new?

07-17-2002, 03:26 PM
Ok, I tried it and it does work in Access - but it only gives you the last two digits of the year (not a problem)...

Just name your field something like TheDate, make it a Date/Time field (make sure you do this in Design View) and below, where it says "Default Value" put (Date()).

Try it out!

07-18-2002, 12:24 AM
Default value!

I forgot about that...

And you said it only gives you the last two digests of the year? What version of access you do have, 98? In 2000, it seems to be the same! I am gunna use this!

Thank you Whammy, it must of been all the scripts i have downlaoded and learned from that made me think if i wanted the date i need to add it in the code.


I still wonder, it might mess me up again for the date. Because I inserted Now() into the db, now i am doing the same thing but having the date just be ready to be put in the db by default.

If I don't know why it happened int he first place, there is no way of me stoping it from happening again.

It has happened with a number of db's that hav had the date added to them.

I would love to know of anyone else that had this problem, and I would love to know if it's just me. Cause if it is, it could of been that I had my setting as dd/mm/yyyy at one point after a format, even though, i don't remember changing anything like that.

That is why i came up with the code:
StrWhen = Month(Now()) & "/" & Day(Now()) & "/" & Year(Now()) & " " & FormatDateTime(Now(), vbLongTime)

Well see what happens in the future :)