Results 1 to 6 of 6

Thread: sql problem.

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2003
    Posts
    62

    sql problem.

    rs.Open "SELECT * FROM [transaction] WHERE t_date=" & Date, db, adOpenStatic, adLockOptimistic


    hi...
    this sql query didn't work?????

    t_date is a date/time (data type) field in access database...

    i can't compare it with the current date.....so that all those records with the current date can display in a listview control...

    in the database there is a few records which its t_date field is current date....but when i compare it with the sql query above...it didn't match and didn't display in the listview control..

    how to compare it??
    what is the problem??

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Try this:
    VB Code:
    1. rs.Open "SELECT * FROM [transaction] WHERE t_date=#" & Format(Date, "mm/dd/yyyy") & "#", db, adOpenStatic, adLockOptimistic
    Unless yopu are using SQL Server, inwhich case try this:
    VB Code:
    1. rs.Open "SELECT * FROM [transaction] WHERE t_date='" & Format(Date, "mm/dd/yyyy") & "'", db, adOpenStatic, adLockOptimistic
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    You have to surround dates w/a # sign in Access

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2003
    Posts
    62
    yeah it works..

    actually what is the problem of my code??

    may u clarify me???

    what is the # means??

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2003
    Posts
    62
    ok...thanks ...hehe..

  6. #6
    Addicted Member
    Join Date
    Apr 2002
    Location
    INDIA
    Posts
    169

    TRY THIS

    Dim rs As New ADODB.Recordset
    str = "Select * from Transaction where t_date < " & "#" & DTP1.Value & "#"

    rs.Open str, Connection.cn, adOpenKeyset, adLockOptimistic

    BE HAPPY BE WELL!!!!

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