select off SQL date

Results 1 to 2 of 2

Thread: select off SQL date

  1. #1
    Trent Gillespie Guest

    Default select off SQL date

    I want to run a select statement off of a date in a SQL table, but I can&#039t figure out the syntax to query on. I&#039ve read on the DateTime type, but I can&#039t figure out how to convert the date I need to the bytes needed by the DateTime type.. i.e, if I need to search for 09/28/2000, what do I put in a query? <BR><BR>Thanks!!!

  2. #2
    Join Date
    Dec 1969

    Default RE: select off SQL date

    In Access:<BR><BR>SQL = "SELECT * FROM table WHERE someDateField = #" & someDateVariable & "#"<BR><BR>In any other DB: <BR><BR>SQL = "SELECT * FROM table WHERE someDateField = &#039" & someDateVariable & "&#039"<BR><BR>The "someDateVariable" in VBS could be a string (e.g., "9/28/2000") or it could be a Date expression of some kind (e.g., Date( ) -- a call to a function that returns today&#039s date) or even the result of user input from a form, in which case you should probably validate it with the CDate function first, as in:<BR><BR>someDateVariable = CDate( Request.Form("someDateFieldOnSomeForm") )<BR><BR>Hope you don&#039t mind my saying this, but I don&#039t think much of whatever resources you have been using up until now if they didn&#039t discuss this kind of stuff! Heck, you could use HELP from within Access to get the basic info, for example.<BR><BR>

Posting Permissions

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