Re: Dates in a SQL Statement



I would use the following:
strSQL = "SELECT * FROM tblMain WHERE [fldDateFrom] = '" &
Format(dateFrom,"yyyy-mm-dd") & "'"



On 30 May, 15:40, NateBuckley <NateBuck...@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:
Hello,

I'm using ADODB to connect to an ACCESS database I've set up. I have a few
fields that are Date types and I send the SQL statement via a string, the
thing is I'm getting errors when trying to use Variables that are dates in
the string.

My SQL Statement

strSQL = "SELECT * FROM tblMain WHERE [fldDateFrom] = '" & dateFrom & "'"

it'll turn my variable dateFrom into just a string. So doesn't match up when
it comes to putting this value into the database.

Anyway to make sure this gets put in as a Date type?

Sorry If that's unclear.

Nate

.



Relevant Pages

  • Re: how do you update a java.sql.date type in an ms access database
    ... > when i update a row in an access database the date field ... DateTime data type in Access/Jet is more like a java.sql.Timestamp. ... Well, partly, but you're not using the date AS a date in the SQL statement, ... but as a String. ...
    (comp.lang.java.help)
  • Re: Send Message to filemaker 5.5 from windows form application
    ... Script created by Steve Carson and it was modified by Kristina ... ' Chrto represent double quotes if you are passing a string. ... Dim pHyperlink As IHyperlink ... 'opens Microsoft Access database ...
    (comp.databases.filemaker)
  • Re: email report per record
    ... is a couple of Access database ... Dim strSubject As String 'Email Subject ... Dim stDocName As String ...
    (microsoft.public.access.reports)
  • Network user count question
    ... an MS Access database on a network server? ... Public Function AddUser(mUserID As String, ... Dim bOK As Boolean ... Dim obj As User ...
    (microsoft.public.vb.database.ado)
  • Cannot Open Any more databases
    ... records from an Access database. ... Function PopDataTable(ByVal ods As DataSet, ByVal sTable As String, ... OleDbConnection = Nothing, Optional ByVal ocomSel As OleDbCommand = ... sRelation, shChildCount) ...
    (microsoft.public.dotnet.framework.adonet)