Results 1 to 5 of 5
  1. #1
    OceanaPolynom is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    20

    sql error when day part of date starts with a zero

    Hello
    I am using VB 6 to program a Access 2003 type database file. This is the code that creates the sql expression

    Code:
    ssql = "select * from tblraw where (tblraw.rawdate=#" & thisdate & "#) and (tblraw.rawcn=" & Trim(Str(thiscow&)) & ") order by tblraw.rawdate,tblraw.rawtime"
    Typically the sql string looks like this :

    select * from tblraw where (tblraw.rawdate=#10/10/2012#) and (tblraw.rawcn=2482) order by tblraw.rawdate,tblraw.rawtime

    the above statement returns 12 records, which is correct

    however if the string looks like this :
    select * from tblraw where (tblraw.rawdate=#09/10/2012#) and (tblraw.rawcn=2482) order by tblraw.rawdate,tblraw.rawtime


    or this :
    select * from tblraw where (tblraw.rawdate=#9/10/2012#) and (tblraw.rawcn=2482) order by tblraw.rawdate,tblraw.rawtime

    then zero records are returned, although they exist in the database file. I find this most unfair.

    Thank you for any help in advance

    John

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,925
    Field rawdate is a date/time type? Query should work.

    Is the criteria MM/DD/YYYY?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    OceanaPolynom is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    20
    Hello
    rawdate is defined as date/time field
    basic Date command returns dd/mm/yyy
    the Access date fields are dd/mm/yyyy with leading zeros

    the query only seems to work with dates that have no leading zeros

    a date like 09/10/2012 returns no records

    Thanks

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,925
    Regarding international date structure and Access date storage, review http://allenbrowne.com/ser-36.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    OceanaPolynom is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    20
    Hello
    By using Function SQLDate found on Allen Browne s page, the problem was solved immediately
    Many thanks

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

Similar Threads

  1. Replies: 4
    Last Post: 01-09-2013, 11:16 AM
  2. Replies: 1
    Last Post: 10-05-2012, 08:48 AM
  3. Syntax of a Formula using Date Part
    By Huddle in forum Reports
    Replies: 14
    Last Post: 09-25-2012, 12:49 PM
  4. Changing the century part of the date.
    By Chet in forum Queries
    Replies: 2
    Last Post: 05-13-2012, 08:27 PM
  5. Getting Just the Date part of Date/Time field
    By GaryElwood in forum Reports
    Replies: 7
    Last Post: 09-28-2011, 09:58 AM

Tags for this Thread

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