473,763 Members | 3,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error '80040e07' wrong syntax in Date expression

Using Access 2000
Windows Server 2003

The following code worked fine until we moved hosting companies

StartDate = Request.Form("S tartDateMonth") & "/" & Request.Form
("StartDateDay" ) & "/" & Request.Form("S tartDateYear")
EndDate = Request.Form("E ndDateMonth") & "/" & Request.Form
("EndDateDay ") & "/" & Request.Form("E ndDateYear")

sql = "SELECT DISTINCT tblSessions.Vis itorID FROM tblSessions WHERE
tblSessions.Dat eTimeEntrance Between #" & StartDate & " 0:0:1# And #" &
EndDate & " 23:59:59#;"

set RSVisitors = cn.execute("sql ")

Response.write sql gives:

SELECT DISTINCT tblSessions.Vis itorID FROM tblSessions WHERE
tblSessions.Dat eTimeEntrance Between #06/01/2005 0:0:1# And #06/31/2005
23:59:59#;

Now the same code gives an error message:
Microsoft JET Database Engine error '80040e07'

Syntax error in date in query expression 'tblSessions.Da teTimeEntrance
Between #06/01/2005 0:0:1# And #06/31/2005 23:59:59#'.

/stats/stats_detail.as p, line 33

The old hosting company was Win2003, as is the new company. I've tried
changing the order of the date parts (YYYY/MM/DD, MM/DD/YYYY,
YYYY/DD/MM) but nonoe of the formats make a difference.

Any ideas?

TIA
Jul 22 '05 #1
2 6181
Aloof wrote:
Using Access 2000
Windows Server 2003

The following code worked fine until we moved hosting companies

StartDate = Request.Form("S tartDateMonth") & "/" & Request.Form
("StartDateDay" ) & "/" & Request.Form("S tartDateYear")
EndDate = Request.Form("E ndDateMonth") & "/" & Request.Form
("EndDateDay ") & "/" & Request.Form("E ndDateYear")

sql = "SELECT DISTINCT tblSessions.Vis itorID FROM tblSessions WHERE
tblSessions.Dat eTimeEntrance Between #" & StartDate & " 0:0:1# And #"
& EndDate & " 23:59:59#;"

set RSVisitors = cn.execute("sql ")

Response.write sql gives:

SELECT DISTINCT tblSessions.Vis itorID FROM tblSessions WHERE
tblSessions.Dat eTimeEntrance Between #06/01/2005 0:0:1# And
#06/31/2005 23:59:59#;

Now the same code gives an error message:
Microsoft JET Database Engine error '80040e07'

Syntax error in date in query expression 'tblSessions.Da teTimeEntrance
Between #06/01/2005 0:0:1# And #06/31/2005 23:59:59#'.

/stats/stats_detail.as p, line 33

The old hosting company was Win2003, as is the new company. I've
tried changing the order of the date parts (YYYY/MM/DD, MM/DD/YYYY,
YYYY/DD/MM) but nonoe of the formats make a difference.

Any ideas?

The safest format to use is #YYYY-MM-DD hh:mm:ss# (note the hyphens), so if
you persist in using dynamic sql, that is the format you should use.

You would be better off using parameters, either via saved parameter
queries:
http://groups.google.com/groups?hl=e...TNGP11.phx.gbl

or using ODBC parameter markers in your sql string, and using a Command
object to pass the parameter values:
http://groups-beta.google.com/group/...e36562fee7804e

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #2
Aloof wrote:
Using Access 2000
Windows Server 2003

The following code worked fine until we moved hosting companies

StartDate = Request.Form("S tartDateMonth") & "/" & Request.Form
("StartDateDay" ) & "/" & Request.Form("S tartDateYear")
EndDate = Request.Form("E ndDateMonth") & "/" & Request.Form
("EndDateDay ") & "/" & Request.Form("E ndDateYear")

sql = "SELECT DISTINCT tblSessions.Vis itorID FROM tblSessions WHERE
tblSessions.Dat eTimeEntrance Between #" & StartDate & " 0:0:1# And #" &
EndDate & " 23:59:59#;"

set RSVisitors = cn.execute("sql ")

Response.write sql gives:

SELECT DISTINCT tblSessions.Vis itorID FROM tblSessions WHERE
tblSessions.Dat eTimeEntrance Between #06/01/2005 0:0:1# And #06/31/2005
23:59:59#;

Now the same code gives an error message:
Microsoft JET Database Engine error '80040e07'

Syntax error in date in query expression 'tblSessions.Da teTimeEntrance
Between #06/01/2005 0:0:1# And #06/31/2005 23:59:59#'.

/stats/stats_detail.as p, line 33

The old hosting company was Win2003, as is the new company. I've tried
changing the order of the date parts (YYYY/MM/DD, MM/DD/YYYY,
YYYY/DD/MM) but nonoe of the formats make a difference.

Any ideas?

TIA

In addition to Bob's reply, there is no 31st June. That's why your
expression doesn't evaluate. You need to test for/prevent invalid
dates being entered into your form.

Paxtonend

Jul 22 '05 #3

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

Similar topics

5
1688
by: Phil Powell | last post by:
select event_date, event_name, event_text, event_is_public, event_is_reserved, event_img_path, event_img_alt, event_member_id, event_is_email_notify from event where show_entry = '1' and ((Year(event_date) = #2004# and event_is_reserved = '0') or event_is_reserved = '1' ) produces this error: Microsoft JET Database Engine error '80040e07'
0
1193
by: Morten Gulbrandsen | last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> select database(); +------------+ | database() | +------------+
8
2728
by: Zibi | last post by:
I have some problem with datatime. SELECT * FROM stat WHERE data > '2005-05-24 14:07:28' ORDER BY id Asc I got the error: Microsoft OLE DB Provider for SQL Server error '80040e07' The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
7
6883
by: John Øllgård Jensen | last post by:
Hi Using MS Asccess 2000: In a query I'm trying to create a new field with following expression: FilmDate: Left(,4) The field "FilmNo" is another text field in the query. This is expression should return the 4 leftmost characters of the FilmNo
3
3100
by: divya | last post by:
Hi, I have a table tblbwday with 2 fields Name and Birthday.I have written this script for displaying evryday names of the people on that day. <% set objConn =server.createobject("ADODB.connection") objConn.open "DSN=Photo" Dim sqlSELsite,ObjRSSel sqlSELsite = "SELECT Name FROM tblbwday WHERE B'day ="& date() &" " '
3
4929
by: access baby | last post by:
I hava a date parameter filter query but it shows error Syntax error missing operator in query experssion can some one please help where am i going wrong in expression SELECT copyorderdtl * from copyorderdtl where(((cr_created_date)is Null) and ((cr_statusupdt_date)=)) OR (((cr_created_date) is not null and (cr_statusupdt_Date)=));
2
5578
by: Rheal | last post by:
Hi Can someone help me. My error is : Microsoft OLE DB Provider for ODBC Drivers error '80040e07' Data type mismatch in criteria expression. /add.asp, line 73 my codes are <% dim DataCon, rsRec, strSql, strSql2, rsRec2 set DataCon = server.createobject("ADODB.Connection")
5
12333
by: OzNet | last post by:
Can someone tell me what I am doing wrong here please? I have a form with two unbound text boxes formatted to short date and an OK button. My button code is as follows: Private Sub cmdOK_Click() Dim strFilter As String
7
2846
by: Yesurbius | last post by:
I am receiving the following error when attempting to run my query. In my mind - this error should not be happening - its a straight-forward query with a subquery. I am using Access 2003 with all the latest patches. If I do not group the query (ie. remove aggregation) it will work. If I recall, it also works if my subquery does not have joins. I want to accomplish this with pure SQL .. I could easily write a VBA function to handle...
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9997
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7366
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.