473,399 Members | 3,919 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,399 software developers and data experts.

Date search error

65 64KB
I just cant find the error in an SQL Statement that I have.

I am using Acess 2010. Im trying to search in a table from a form using date as the search Parameter.

Expand|Select|Wrap|Line Numbers
  1. "SELECT * INTO [new] FROM [projectsearch]" & _
  2.         " WHERE [projectsearch].[Delivery Date] BETWEEN #" & Me.datefrom & "# and #" & Me.dateto & "#;"
I have two text boxes with a date picker in the form.

But when I run this SQL I get an error stating Syntax error in the date.

Does anybody see where the error lies.

Thanks in advance.
Mar 21 '16 #1
4 2759
MikeTheBike
639 Expert 512MB
Hi

you could try this
Expand|Select|Wrap|Line Numbers
  1. "SELECT * INTO [new] FROM [projectsearch]" & _
  2.          " WHERE [projectsearch].[Delivery Date] BETWEEN #" & Format(Me.datefrom,"mm/dd/yyyy") & "# and #" & Format(Me.dateto,"mm/dd/yyyy") & "#;"
The dates should be formatted as strings in sql statements, and in American or universal date format.
HTH

MTB
Mar 21 '16 #2
saranmc
65 64KB
thanks you for your answer!
what happens when I try it is that, my date Format is being changed.
For example if I enter 01.03.2016, it becomes 03.01.2016 in the SQL. this is wrong. It is searching for the wrong values.
Mar 24 '16 #3
PhilOfWalton
1,430 Expert 1GB
Try changing the date format to "mmm-dd-yyyy"
That should always show month 3 as Mar

Phil
Mar 24 '16 #4
MikeTheBike
639 Expert 512MB
Well I have 2 comments
1) I incorrectly assumed that datefrom etc. are actually dates
2) I have never used periods(.) as separator in a date, I have always a slash (/) from well before computer where in the public consciousness, but it would seem people has started using a period and I have no idea why.
This practice also plays havoc in Excel if you want to use it in a calculation/function.

So, using a slash may solve (part) of the problem??

MTB
Mar 24 '16 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Greg | last post by:
I have a page that searches a database by a repairman's name and by a date range. It pulls info by the repairman's name but pulls all info in the database regardless of the date. Below is the code...
1
by: trhq | last post by:
I have to extract date info from a memo field. How can I do a date search (mm/dd/yy date format) on the memo field in a single pass.?
2
by: DD | last post by:
The user needs to search by a date they enter into the searchField my code is NOT working can anyone advise where i am going wrong please Regards DD Private Sub cmdFind_Click() Dim...
8
by: kevcar40 | last post by:
Hi I have a excel worksheet that contains a lot of data one on the columns is the date(formatted as short date "dd/mm/yyyy) i import this worksheet into access as a table the date field is...
1
by: balleyman47 | last post by:
getting the following error when executing an insert statement: java.lang.IllegalArgumentException: Date/Time must be JDBC format running on UDB 8.2 fix pack 10 using IBM type IV driver. Query...
0
by: trishbarker | last post by:
I've created a simple select query in Microsoft Access wherein I'm searching all records based on the "Final Payment Due Date". The Final Payment Due Date is a calculated expression based on two...
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...
3
by: Bhari | last post by:
Hi all, I need to search for a date field in 'MM-DD-YYYY' format.. any suggestions for this??? MY field is of datetime type...is this okay for the above format to search..
0
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
Hello group. I've migrated from Win 2003 server to Win 2008 server. I've been banging my head agaist a wall for several days now trying to figure this out. I have the following script that will...
0
by: santhanalakshmi | last post by:
Hi, Please help me out. I have successfully binded to my ADSI server(windows 2003 machine) from my windows XP machine? #LDAP SEARCHING my $ldapSearch = $ldap->search(base...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.