Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post

    Angry Access Date error?

    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?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!
    Last edited by whammy; 07-17-2002 at 02:32 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #3
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    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?

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #5
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    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.

    Hum...



    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •