DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2004
    Location
    Northampton,United Kingdom
    Posts
    230

    Problem with SQL Select command

    hi all,

    can someone please help me I am having problems with this SQL Select command

    Code:
    SQLCommand = SQLCommand & "WHERE JournalDate Between '" & FrmJournalRoll1.txtStartDate.Text & "' AND '" & FrmJournalRoll1.txtEndDate.Text & " AND PoSNumber='" & FrmJournalRoll1.txtPoS.Text & "'"
    If I enter in example 12/10/2009 in both the txtstartDate (text box) and 12/10/2009 it finds everything with no errors.

    BUT if I enter a wide date range say 01/09/2009 to 20/09/2009 it is finding dates from 01/01/2007 and 01/01/2009 can someone please point out where I am going wrong?

    Thanks
    Drew

    EPoS made simple
    www.jasonpos.co.uk | www.jasonpos.com

  2. #2
    Join Date
    Mar 2009
    Location
    Italy - Breganze (VI)
    Posts
    120

  3. #3
    Join Date
    Sep 2004
    Location
    Northampton,United Kingdom
    Posts
    230
    Database is SQL Server 2005 Express
    date format is DD/MM/YYYY (eg 01/11/2009)
    Drew

    EPoS made simple
    www.jasonpos.co.uk | www.jasonpos.com

  4. #4
    Join Date
    Mar 2009
    Location
    Italy - Breganze (VI)
    Posts
    120

  5. #5
    Join Date
    Sep 2004
    Location
    Northampton,United Kingdom
    Posts
    230
    SELECT * from JournalRoll WHERE JournalDate Between '01/09/2009' AND '20/09/2009' AND PoSNumber='001'

    this is what is printed in the debug window
    Last edited by Drew_gable; 11-03-2009 at 10:09 AM.
    Drew

    EPoS made simple
    www.jasonpos.co.uk | www.jasonpos.com

  6. #6
    Join Date
    Mar 2009
    Location
    Italy - Breganze (VI)
    Posts
    120
    Quote Originally Posted by Drew_gable View Post
    SELECT * from JournalRoll WHERE JournalDate Between '01/09/2009' AND '20/09/2009' AND PoSNumber='001'

    this is what is printed in the debug window
    OK, the SQL string seem to be correct.
    JournalDate is a String or Date field type?

Similar Threads

  1. data environment SQL command
    By helme_syahiemie in forum VB Classic
    Replies: 4
    Last Post: 09-05-2007, 03:11 PM
  2. How do I find duplicate records?
    By Nancy in forum Database
    Replies: 2
    Last Post: 01-11-2002, 09:38 PM
  3. SELECT INTO..# performance in SQL 7.0
    By David Miller in forum Database
    Replies: 1
    Last Post: 01-18-2001, 05:33 PM
  4. Re: Sort problem in MS SQL Server 7.0
    By D. Patrick Hoerter in forum Database
    Replies: 1
    Last Post: 06-26-2000, 04:57 PM
  5. Replies: 0
    Last Post: 06-22-2000, 07:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links