Results 1 to 5 of 5
  1. #1
    abodi is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    31

    Advice on dealing with Access' ## expecting an american date.

    Hi Everyone.

    So I'm in Australia, and we use DD/MM/YYYY.
    Our local system settings specify that formating and it works fine.

    However on a form I'm using a dcount to count the number of entries that exist on that date and has the status approved.
    This is the code I used (Thanks June7).

    Code:
    =DCount("*","[tblLeaveRequests]","Status='Approved' And #" & CDate([vDate1]) & "# BETWEEN [LeaveStartDate] AND [LeaveEndDate]")
    This is where the problem occurs though. The above code doesn't work without # #, but the # also then expects the date to be in an american format and is screwing up the counting.

    Click image for larger version. 

Name:	Dcount2.PNG 
Views:	18 
Size:	8.8 KB 
ID:	17925



    As you can see 04/08 - 07/08 it's counts zero. that because it is looking for the 8th Feb. you'll see from the 13/08 it's counting and that because access goes "oh damn, it must be the other way around" and then counts correctly.

    From a usability point of view when entering dates into the DB users need to be in DD/MM/YYYY format, just to make it fool proof/user friendly.

    I've done a bit of googling, but i've not found something that kickstarts my brain to a solution. so how can I work around/with this issue?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    abodi is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    31
    Pbaldy, i've read that at least twice at this point, but I really can't parse that into a solution.

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    Instead of using CDate, use the Format function:

    =DCount("*","[tblLeaveRequests]","Status='Approved' And #" & format([vDate1],"mm/dd/yyyy") & "# BETWEEN [LeaveStartDate] AND [LeaveEndDate]")

    to put the date in the required format.

    John

  5. #5
    abodi is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    31
    Thank you so much John, that was a revelation.

    I decided to get out of the building for lunch to try clear the cobwebs. I think i thought of another solution, but yours is much more elegant and simple!

    Thank you pbaldy, combined with Johns reply, i now understand the link you provided.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. New to Access, in need of some advice
    By jdailey in forum Access
    Replies: 4
    Last Post: 03-26-2014, 02:40 PM
  2. Replies: 3
    Last Post: 01-30-2012, 09:57 AM
  3. Error 3061 Too Few Parameters Expecting 1
    By ironman in forum Programming
    Replies: 4
    Last Post: 05-09-2011, 03:20 PM
  4. Replies: 1
    Last Post: 04-22-2011, 08:40 AM
  5. American/European date format issue
    By dantnz in forum Programming
    Replies: 2
    Last Post: 12-09-2010, 03:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums