473,406 Members | 2,273 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,406 software developers and data experts.

select records between dates - query works in VS 2005 but it doesn't in asp 3

Hello. I'm having troubles with a query that (should) return all the
records between two dates. The date field is a datetime type. The db is
SQL Server 2000. When I try this

SELECT RESERVES.RES_ID, PAYMENTS_RECEIVED.PYR_ID,
PAYMENTS_RECEIVED.PYR_VALUE, PAYMENTS_RECEIVED.PYR_DATE,
CUSTOMERS.CUS_NAME
FROM RESERVES LEFT OUTER JOIN
PAYMENTS_RECEIVED ON RESERVES.RES_ID =
PAYMENTS_RECEIVED.RES_ID LEFT OUTER JOIN
CUSTOMERS ON RESERVES.CUS_ID = CUSTOMERS.CUS_ID
WHERE (PAYMENTS_RECEIVED.PYR_DATE >= '2006-03-20 00:00:00') AND
(PAYMENTS_RECEIVED.PYR_DATE < '2006-03-27 00:00:00')

on a "query builder" in visual studio, I get the results that I want.
But when I use exactly the same query on an asp 3 vbscript script, I
get no results (an empty selection).
I've done everything imaginable. I wrote the date as iso, ansi, british
format using convert(,103) (that's how users will enter the dates),
i've used cast('20060327' as datetime), etc. But I can't still get it
to work. Other querys from the asp pages work ok. Any ideas?

thanks a lot in advance

Nov 9 '06 #1
1 4722
(sa******@partirviajes.com.ar) writes:
Hello. I'm having troubles with a query that (should) return all the
records between two dates. The date field is a datetime type. The db is
SQL Server 2000. When I try this

SELECT RESERVES.RES_ID, PAYMENTS_RECEIVED.PYR_ID,
PAYMENTS_RECEIVED.PYR_VALUE, PAYMENTS_RECEIVED.PYR_DATE,
CUSTOMERS.CUS_NAME
FROM RESERVES LEFT OUTER JOIN
PAYMENTS_RECEIVED ON RESERVES.RES_ID =
PAYMENTS_RECEIVED.RES_ID LEFT OUTER JOIN
CUSTOMERS ON RESERVES.CUS_ID = CUSTOMERS.CUS_ID
WHERE (PAYMENTS_RECEIVED.PYR_DATE >= '2006-03-20 00:00:00') AND
(PAYMENTS_RECEIVED.PYR_DATE < '2006-03-27 00:00:00')

on a "query builder" in visual studio, I get the results that I want.
But when I use exactly the same query on an asp 3 vbscript script, I
get no results (an empty selection).
I've done everything imaginable. I wrote the date as iso, ansi, british
format using convert(,103) (that's how users will enter the dates),
i've used cast('20060327' as datetime), etc. But I can't still get it
to work. Other querys from the asp pages work ok. Any ideas?
This is how the query in the ASP page should look like:

SELECT RESERVES.RES_ID, PAYMENTS_RECEIVED.PYR_ID,
PAYMENTS_RECEIVED.PYR_VALUE, PAYMENTS_RECEIVED.PYR_DATE,
CUSTOMERS.CUS_NAME
FROM RESERVES LEFT OUTER JOIN
PAYMENTS_RECEIVED ON RESERVES.RES_ID =
PAYMENTS_RECEIVED.RES_ID LEFT OUTER JOIN
CUSTOMERS ON RESERVES.CUS_ID = CUSTOMERS.CUS_ID
WHERE (PAYMENTS_RECEIVED.PYR_DATE >= ?) AND
(PAYMENTS_RECEIVED.PYR_DATE < ?)

and you should pass the dates in the parameters collection, using the
..Create Parameter method. The dates will then be interpreted according
to the regional settings on the machine and passed as binary values
to SQL Server.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Nov 9 '06 #2

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

Similar topics

5
by: J. Muenchbourg | last post by:
I would like to grab the earliest date of any of the records that gets drawn from this SQL statement: datesql = "SELECT top 1 gamedate FROM tblNFLGameData WHERE season = '" & seasonZ & "' and...
3
by: Randell D. | last post by:
Folks, I'm working on an ecommerce website that deals with credit card expiry dates. The table has two columns for year and month. I currently have a select that says: ...
2
by: David | last post by:
Hi, I have part of my SQL statement in my asp page as follows: WHERE ((pcbforecast.ShipETA < '31/12/2005') and (products.BBProductName = ....... The problem I am having is that I want the...
4
by: psql-mail | last post by:
I am running a SELECT to get all tuples within a given date range. This query is much slwoer than i expected - am i missing something? I have a table 'meta' with a column 'in_date' of type...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
2
by: rivka.howley | last post by:
I wrote some code that creates a table with a date/time field at 15-minute intervals. Here's how I create and populate the table With tblDataTemp ..Fields.Append .CreateField("CT_ID", dbLong)...
5
by: Henning M | last post by:
Hi all, I having some problems with Access and selecting records between dates.. When I try this in access, it works fine!! "Select * from Bilag Where Mdates Between #1/1/2006# And...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
2
by: Mark Roughton | last post by:
I have a form where the users need to view records for various criteria, one of which is a date field on which they may wish to view all related data for the selected date, for all dates upto and...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.