Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2004
    Posts
    1

    Cool Unanswered: Convert Date in SQL - Query

    Hi

    im using access 2000 with ASP.

    i do have the following query

    SQL = "SELECT * FROM tblKundenstamm, tblVertrag " _
    & "WHERE tblVertrag.strKSID = tblKundenstamm.IDRef AND strDate BETWEEN " & CDate(firstDate) & " AND " & CDate(lastDate) & " " _
    & "ORDER BY tblKundenstamm.strFirma, tblVertrag.strVertragNr"

    strDate is not a Date/Time Field, it is a text field.

    How do i convert strDate into a Date within this query?

    thanks

  2. #2
    Join Date
    Sep 2003
    Posts
    6
    Hi,

    To convert strDate into a Date within this query : (first the conversion is done in date and then for checking with firstdate and lastdate all the three dates are converted back to character in ddmmyyyy format. The format can be anything, but all should have the same format.)

    SQL = "SELECT * FROM tblKundenstamm, tblVertrag " _
    & "WHERE tblVertrag.strKSID = tblKundenstamm.IDRef AND
    to_char(to_date(strDate,'ddmmyyyy'),'ddmmyyyy')
    BETWEEN " & to_char(firstDate,'ddmmyyyy') & " AND " & to_char(lastDate,'ddmmyyyy') & " " _
    & "ORDER BY tblKundenstamm.strFirma, tblVertrag.strVertragNr"


    Thanks ...
    Bye

Posting Permissions

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