473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Date Error

Hello:

I have an access database that stores employee timings by date.
At the same time, I have a form that queries this database.
On the form I use a DTpicker to enable a user input the date for which
he/she wants data
When I execute the query below in my VB code, I get a run time error
that says
Error ===> "Datatype mismatch in criteria expression."
Query ===> cmdQuery.CommandText = "SELECT * from tblTimings WHERE
fldDate = '" & dtpDate.Value & "'"

I don't understand why I get this error when
both, the field fldDate is of type Date/time and dtpDate.Value returns
the same. I tried setting both the DB date and the control date to
different date formats such as short date, long/general date, custom
date, but I still get the same error.
Appreciate any help on resolving this

Jul 17 '05 #1
3 5320
Hi

Try: fldDate = cvdate('" & dtpDate & "'")
instead

Svend
DK
<ka*****@gmail.com> skrev i en meddelelse
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello:

I have an access database that stores employee timings by date.
At the same time, I have a form that queries this database.
On the form I use a DTpicker to enable a user input the date for which
he/she wants data
When I execute the query below in my VB code, I get a run time error
that says
Error ===> "Datatype mismatch in criteria expression."
Query ===> cmdQuery.CommandText = "SELECT * from tblTimings WHERE
fldDate = '" & dtpDate.Value & "'"

I don't understand why I get this error when
both, the field fldDate is of type Date/time and dtpDate.Value returns
the same. I tried setting both the DB date and the control date to
different date formats such as short date, long/general date, custom
date, but I still get the same error.
Appreciate any help on resolving this

Jul 17 '05 #2
.... ups... theres a " too much
this is how: fldDate = cvdate('" & dtpDate & "')

Sorry
Svend

"Svend Erik Johansen" <cr****@mail.dk> skrev i en meddelelse
news:42*********************@dread12.news.tele.dk. ..
Hi

Try: fldDate = cvdate('" & dtpDate & "'")
instead

Svend
DK
<ka*****@gmail.com> skrev i en meddelelse
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello:

I have an access database that stores employee timings by date.
At the same time, I have a form that queries this database.
On the form I use a DTpicker to enable a user input the date for which
he/she wants data
When I execute the query below in my VB code, I get a run time error
that says
Error ===> "Datatype mismatch in criteria expression."
Query ===> cmdQuery.CommandText = "SELECT * from tblTimings WHERE
fldDate = '" & dtpDate.Value & "'"

I don't understand why I get this error when
both, the field fldDate is of type Date/time and dtpDate.Value returns
the same. I tried setting both the DB date and the control date to
different date formats such as short date, long/general date, custom
date, but I still get the same error.
Appreciate any help on resolving this


Jul 17 '05 #3
Should be

cmdQuery.CommandText = "SELECT * from tblTimings WHERE
fldDate = #" & dtpDate.Value & "#"

That is if you are in the USA Europe and Australia will need to do this to
ensure consistent results

cmdQuery.CommandText = "SELECT * from tblTimings WHERE
fldDate = #" &dtpDate.month & "/" & dtpDate.day & "/" dtpDate.year & "#"

SQL Process dates in US Date Format but will not throw an error if you feed
it dd/mm/yy instead it try's to fix it for you so it 1/4/05 will give be
processed as 4 January where as 13/4/05 will be processed as 13 April go
figure !


<ka*****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello:

I have an access database that stores employee timings by date.
At the same time, I have a form that queries this database.
On the form I use a DTpicker to enable a user input the date for which
he/she wants data
When I execute the query below in my VB code, I get a run time error
that says
Error ===> "Datatype mismatch in criteria expression."
Query ===> cmdQuery.CommandText = "SELECT * from tblTimings WHERE
fldDate = '" & dtpDate.Value & "'"

I don't understand why I get this error when
both, the field fldDate is of type Date/time and dtpDate.Value returns
the same. I tried setting both the DB date and the control date to
different date formats such as short date, long/general date, custom
date, but I still get the same error.
Appreciate any help on resolving this

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Jack | last post by:
Hi, I cannot get the date format correctly in dynamic sql statement, after trying various ways of handling it. I need some help with the date format in the following dynamic sql statement. Any...
15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
32
by: paul | last post by:
HI! I keep on getting this error and I have tried different things but I am not sure how to send the expiring date. The error that I am getting in Firefox 1.5 is "Error: expires.toGMTString is...
1
by: JonathanParker | last post by:
Another quick one! Trying to search for records by both accounting period and by year in two seperate queries actioned by option buttons. I've sorted the formatting so it's in a UK format but I...
6
by: Jana | last post by:
Greetings Access Gurus! I am working on an app to send batch transactions to our bank, and the bank requires that we place an effective date on our files that is 'one business day in the future,...
3
by: bhavu10 | last post by:
hi i have created a form forreport with today, week month & year CMD Button but i think i wrote the code wrong for month and also it shows me only records for this year whewe as i have 2006...
2
by: LadySugar | last post by:
Greetings! I have a database in access that contains information about the date members joined the company. Every year, membership must be renewed for each member. Usually I will send out a...
5
Stang02GT
by: Stang02GT | last post by:
I have been asked to validate a date on our web-page so that people cannot enter dates like 14/1/08 or 2/30/06. I have found code that will do exactly what i need it to do, but i am not sure how to...
6
by: DavidPr | last post by:
I have a website that allows people to post ads. Ads remain active for 30 days. In their control panel they can manage their ads, i.e., Edit, Delete, Renew, etc. In this case I'm working with the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.