Hello,
I have a Acces database and vbnet2008.
When i run the qwery below i've got the error message " Data Type Mismatch in Criteria Expression"
strSQL = "Select * FROM Cars WHERE " & strChoice & "=" & "'Yes' AND DateMake BETWEEN '" & dtpBegin.Value & "' AND '" & dtpEnd.Value & "'"
Where DateMake is a date in the Acces dbase and save as date
dtpBegin and dtpEnd are dates from a datetimepicker in the program
When i'm looking at the dates in Watch there no different between the "looking"of the dates
Whats wrong?
Thanks
Dates Acces versus SQLProblem with dates in Select statement
Page 1 of 1
4 Replies - 761 Views - Last Post: 09 November 2009 - 11:40 PM
Replies To: Dates Acces versus SQL
#3
Re: Dates Acces versus SQL
Posted 08 November 2009 - 01:11 PM
Try enclosing the dates in # instead of '
so WHERE Date between #01/01/2009# and #01/31/2009#
so WHERE Date between #01/01/2009# and #01/31/2009#
#4
Re: Dates Acces versus SQL
Posted 09 November 2009 - 08:48 AM
CharlieMay, on 8 Nov, 2009 - 12:11 PM, said:
Try enclosing the dates in # instead of '
so WHERE Date between #01/01/2009# and #01/31/2009#
so WHERE Date between #01/01/2009# and #01/31/2009#
thats works perfect, but i'm working with datetimepickers so i want use them values
still, why did it work with your solution and not with de datetimepickers values???
#5
Re: Dates Acces versus SQL
Posted 09 November 2009 - 11:40 PM
Hi,
I access, date value have to be enclosed with the hashes in sql statements like this #01-01-2000#. In MSSQL its done with single quotes. like this '01-01-2000'.
Just mind the format of your date. I prefer sending it like this #01-Jan-2000# (Access) or '01-Jan-2000' (MSSQL).
I access, date value have to be enclosed with the hashes in sql statements like this #01-01-2000#. In MSSQL its done with single quotes. like this '01-01-2000'.
Just mind the format of your date. I prefer sending it like this #01-Jan-2000# (Access) or '01-Jan-2000' (MSSQL).
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|