Results 1 to 11 of 11
  1. #1
    Join Date
    Aug 2003
    Location
    Cleveland USA
    Posts
    184

    Question Unanswered: What is the difference between Date and Date()?

    I have some code where a date field is set to Date on a form when the user clicks a button (other stuff goes on too). Ex:

    Me.datDateCompleted = Date


    However, it doesn't seem to work, because the date field is sitting blank. Is this a valid function? Should it be Date() instead? I've used Now() in other circumstances but this time around I don't want the time included.

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I've had this happen before and it was the product of an outdated vb library reference. Have you run office update lately?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    I've used Now() in other circumstances but this time around I don't want the time included

    mmmm!

    the time is going to get included whether you want it or not! Date() returns (if anything!!!) the same as Now() but with the time set to 00:00:00 (the fractional part after the decimal of the datetime (datatype=double) set to 0)

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Aug 2003
    Location
    Cleveland USA
    Posts
    184
    Shoot, I get the time anyway? Wouldn't CDate() fix that? It's not the end of the world, I just need to check my queries that filter by date.

    Thanks, it could be the library reference. I'll have to switch back to Now() since I am not sure I'm allowed to get Office Updates (we've got some serious limitations for security reasons), let alone make sure all the users do the same.

    Good one about the requirements, Teddy.

  5. #5
    Join Date
    Mar 2007
    Posts
    277
    You don't happen to have a field or control named Date as well do you?
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  6. #6
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    Have a feild name call Date will Do this

    the computer does know what to do

    is it the Date function or the date feild

    Been there done that

    also don't use
    name <= this will cause heap of problem when you get in the coding side of the database
    date
    max
    min
    first
    last
    ...
    ...

    When I Using dates
    Pdate = paid date
    Idate = invoice date
    jdate = join date
    ....
    ....
    ....
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  7. #7
    Join Date
    Mar 2007
    Posts
    277
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  8. #8
    Join Date
    Aug 2003
    Location
    Cleveland USA
    Posts
    184
    Thanks, I'll check for a control named Date. I haven't been the only programmer on this database. I know there's no field by that name, I've already found out the hard way about that.

  9. #9
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    441
    If it's a missing reference, I think you should probably have problems with more functions.

    If Date is a method of more than one library, or you have something called Date somewhere, you should be able to get around it in code by prefixing with library

    VBA.Date
    VBA.DateTime.Date

    Or you could use something like Int(Now)

    Difference between Date and Date(). As far as I know, it is the same function. In code, parenthesis isn't needed, but in the interface (default values, controlsources, queries...), you need the parenthesis.
    Roy-Vidar

  10. #10
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by RoyVidar
    If it's a missing reference, I think you should probably have problems with more functions.

    If Date is a method of more than one library, or you have something called Date somewhere, you should be able to get around it in code by prefixing with library

    VBA.Date
    VBA.DateTime.Date

    Or you could use something like Int(Now)

    Difference between Date and Date(). As far as I know, it is the same function. In code, parenthesis isn't needed, but in the interface (default values, controlsources, queries...), you need the parenthesis.
    That's what I thought when I came across this as well. I won't claim to fully understand the inner workings of how the different vba libraries are developed, but for whatever reason updating the vba library worked when I experienced a similar scenario. Your mileage may vary.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  11. #11
    Join Date
    Jan 2007
    Location
    California, USA
    Posts
    520
    LisaChow,
    the time is going to get included whether you want it or not! Date() returns (if anything!!!) the same as Now() but with the time set to 00:00:00 (the fractional part after the decimal of the datetime (datatype=double) set to 0)
    I just wanted to comment about this statement about "The time is going to get included..." There is a very strict, technical way that we can say "the time will be included" but in everyday programming, it is very easy, and I see nothing wrong with, looking at Date() or Date as NOT having the time included. The very fact that the Date function returns the date with the time portion of a DateTime field set to zeros, means the time is a non-factor, therefore best to look at it as NO time.

    Hope this helps,

Posting Permissions

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