Results 1 to 3 of 3

Thread: [RESOLVED] Dates in SQL Query

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    UK
    Posts
    489

    Resolved [RESOLVED] Dates in SQL Query

    Hi

    I have an SQL between query, which searches an Access database for records between the two dates specfied, however I have noticed that it only looks at the dat number, and not the month or year, for example, say I specified the following date

    23/03/2008
    28/03/2008

    It would return

    25/03/2008
    24/01/2008
    27/09/2007 etc

    Hes my sql query

    Code:
    sqlstring = "SELECT ID, Problem, SubmittedAt, Viewed FROM Table1 WHERE SubmittedAt BETWEEN #" & Olddate & "# AND #" & ObjDateToday & "# ORDER BY ID DESC"
    Help appreciated
    Learning C♯

    Data Binding & Bound Controls - Objects and wizards will never be as intelligent as you, do it yourself! (Unless your Pro)

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Dates in SQL Query

    It sounds like the SubmittedAt field is a Char/Text data type, rather than a Date data type.

    Another possible issue is the format of Olddate and ObjDateToday.. to be reliable, they need to be in either US (mm/dd/yyyy) or ISO (yyyy-mm-dd) format.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    UK
    Posts
    489

    Re: Dates in SQL Query

    I forgot I changed the Data type to text whilst testing last week, oops.
    Learning C♯

    Data Binding & Bound Controls - Objects and wizards will never be as intelligent as you, do it yourself! (Unless your Pro)

Posting Permissions

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



Click Here to Expand Forum to Full Width