Hi all,
I am trying to retrieve a count of booking entries made 30 days ago, below
is the end of the query I am having problems with.
dbo.booking_form.TimeOfBooking = DATEADD(day, -30, GetDate()) GROUP BY
dbo.booking_form.TimeOfBooking")
When I use the = sign the error reads
Either BOF or EOF is True, or the current record has been deleted. Requested
operation requires a current record.
for the entry on the page
(rsCash30("CountOfTimeOfBooking"))
But I know the record exists, also the query works when I use the signs < or
or <all works ok but not with the = ??
Full SQL query reads
Set rsCash30 = myConn.Execute("SELECT Count(dbo.booking_form.TimeOfBooking)
AS CountOfTimeOfBooking FROM dbo.booking_form WHERE
dbo.booking_form.allocated = 'Completed' AND dbo.booking_form.CustomerID
='0' AND dbo.booking_form.TimeOfBooking = DATEADD(day, -30, GetDate()) GROUP
BY dbo.booking_form.TimeOfBooking")
Regards
--
Simon Gare
The Gare Group Limited
website: www.thegaregroup.co.uk
website: www.privatehiresolutions.co.uk 4 3155
Simon Gare wrote:
Hi all,
I am trying to retrieve a count of booking entries made 30 days ago,
below is the end of the query I am having problems with.
dbo.booking_form.TimeOfBooking = DATEADD(day, -30, GetDate()) GROUP BY
dbo.booking_form.TimeOfBooking")
When I use the = sign the error reads
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.
for the entry on the page
(rsCash30("CountOfTimeOfBooking"))
But I know the record exists, also the query works when I use the
signs < or
>or <all works ok but not with the = ??
Full SQL query reads
Set rsCash30 = myConn.Execute("SELECT
Count(dbo.booking_form.TimeOfBooking) AS CountOfTimeOfBooking FROM
dbo.booking_form WHERE dbo.booking_form.allocated = 'Completed' AND
dbo.booking_form.CustomerID ='0' AND dbo.booking_form.TimeOfBooking =
DATEADD(day, -30, GetDate()) GROUP BY dbo.booking_form.TimeOfBooking")
Regards
I am assuming SQL Server due to the presence of "dbo" in your sql statement.
Please don't make us guess. Always reveal the database type and version when
asking database-related questions.
You need to remember that the datetime datatype stores BOTH time AND date.
They are stored as paired integers: the firs integer contains the number of
days since the seed date, and the second contains the number of milliseconds
since midnight.
So, to see your problem, do this in QA or SSMS:
SELECT Top 10 DATEADD(day, -30, GetDate()) CompareDate,
TimeOfBooking FROM booking_form
Even this small sample should reveal that is is unlikely that booking_form
will ever be EQUAL to DATEADD(day, -30, GetDate()).
I am not sure what you are storing in TimeOfBooking. The name suggests that
you are attempting to store time only. I am not going to waste time
providing what may be an inappropriate solution based on a guess. Tell us
the datatype of TimeOfBooking and show us a few examples of the data it
contains.
Bob Barrorws
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Sorry Bob,
Time of Booking contains Date and Time of vehicle required eg 21/1/2007
9:40:00. The query I am trying to build retrieves a count of the bookings
entered 30 days ago hence the
(SELECT Count(dbo.booking_form.TimeOfBooking) AS CountOfTimeOfBooking FROM
dbo.booking_form WHERE dbo.booking_form.TimeOfBooking = DATEADD(day, -1,
GetDate()) GROUP BY dbo.booking_form.TimeOfBooking")
Obviously the problem is as you described that the stored value is date +
time, can you sugeest an alternative?
Regards
Simon
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Simon Gare wrote:
Hi all,
I am trying to retrieve a count of booking entries made 30 days ago,
below is the end of the query I am having problems with.
dbo.booking_form.TimeOfBooking = DATEADD(day, -30, GetDate()) GROUP BY
dbo.booking_form.TimeOfBooking")
When I use the = sign the error reads
Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.
for the entry on the page
(rsCash30("CountOfTimeOfBooking"))
But I know the record exists, also the query works when I use the
signs < or
or <all works ok but not with the = ??
Full SQL query reads
Set rsCash30 = myConn.Execute("SELECT
Count(dbo.booking_form.TimeOfBooking) AS CountOfTimeOfBooking FROM
dbo.booking_form WHERE dbo.booking_form.allocated = 'Completed' AND
dbo.booking_form.CustomerID ='0' AND dbo.booking_form.TimeOfBooking =
DATEADD(day, -30, GetDate()) GROUP BY dbo.booking_form.TimeOfBooking")
Regards
I am assuming SQL Server due to the presence of "dbo" in your sql
statement.
Please don't make us guess. Always reveal the database type and version
when
asking database-related questions.
You need to remember that the datetime datatype stores BOTH time AND date.
They are stored as paired integers: the firs integer contains the number
of
days since the seed date, and the second contains the number of
milliseconds
since midnight.
So, to see your problem, do this in QA or SSMS:
SELECT Top 10 DATEADD(day, -30, GetDate()) CompareDate,
TimeOfBooking FROM booking_form
Even this small sample should reveal that is is unlikely that booking_form
will ever be EQUAL to DATEADD(day, -30, GetDate()).
I am not sure what you are storing in TimeOfBooking. The name suggests
that
you are attempting to store time only. I am not going to waste time
providing what may be an inappropriate solution based on a guess. Tell us
the datatype of TimeOfBooking and show us a few examples of the data it
contains.
Bob Barrorws
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
You want all records containing that date, regardless of time? First, you
need to calculate today's date at midnight. Here is one way to do that (0
can be used to represent the seed date):
SELECT DATEADD(day,DATEDIFF(d,0,getdate()),0)
Now modify that expression to calculate the date 30 days ago at midinight,
and 29 days ago at midnight:
SELECT DATEADD(day,DATEDIFF(d,0,getdate())-30,0),
DATEADD(day,DATEDIFF(d,0,getdate())-29,0)
Now use those expressions in your Where clause to get all records between
those two dates, excluding the later date, like this:
WHERE TimeOfBooking >=
DATEADD(day,DATEDIFF(d,0,getdate())-30,0) AND
TimeOfBooking < DATEADD(day,DATEDIFF(d,0,getdate())-29,0)
Bob
Simon Gare wrote:
Sorry Bob,
Time of Booking contains Date and Time of vehicle required eg
21/1/2007 9:40:00. The query I am trying to build retrieves a count
of the bookings entered 30 days ago hence the
(SELECT Count(dbo.booking_form.TimeOfBooking) AS CountOfTimeOfBooking
FROM dbo.booking_form WHERE dbo.booking_form.TimeOfBooking =
DATEADD(day, -1, GetDate()) GROUP BY dbo.booking_form.TimeOfBooking")
Obviously the problem is as you described that the stored value is
date + time, can you sugeest an alternative?
Regards
Simon
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Simon Gare wrote:
>>Hi all,
I am trying to retrieve a count of booking entries made 30 days ago, below is the end of the query I am having problems with.
dbo.booking_form.TimeOfBooking = DATEADD(day, -30, GetDate()) GROUP BY dbo.booking_form.TimeOfBooking")
When I use the = sign the error reads
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
for the entry on the page
(rsCash30("CountOfTimeOfBooking"))
But I know the record exists, also the query works when I use the signs < or or <all works ok but not with the = ??
Full SQL query reads
Set rsCash30 = myConn.Execute("SELECT Count(dbo.booking_form.TimeOfBooking) AS CountOfTimeOfBooking FROM dbo.booking_form WHERE dbo.booking_form.allocated = 'Completed' AND dbo.booking_form.CustomerID ='0' AND dbo.booking_form.TimeOfBooking = DATEADD(day, -30, GetDate()) GROUP BY dbo.booking_form.TimeOfBooking")
Regards
I am assuming SQL Server due to the presence of "dbo" in your sql statement. Please don't make us guess. Always reveal the database type and version when asking database-related questions.
You need to remember that the datetime datatype stores BOTH time AND date. They are stored as paired integers: the firs integer contains the number of days since the seed date, and the second contains the number of milliseconds since midnight.
So, to see your problem, do this in QA or SSMS:
SELECT Top 10 DATEADD(day, -30, GetDate()) CompareDate, TimeOfBooking FROM booking_form
Even this small sample should reveal that is is unlikely that booking_form will ever be EQUAL to DATEADD(day, -30, GetDate()).
I am not sure what you are storing in TimeOfBooking. The name suggests that you are attempting to store time only. I am not going to waste time providing what may be an inappropriate solution based on a guess. Tell us the datatype of TimeOfBooking and show us a few examples of the data it contains.
Bob Barrorws -- Microsoft MVP - ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM"
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Bob you're a star, that's been driving me crazy, thanks again.
Regards
Simon
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:ed**************@TK2MSFTNGP06.phx.gbl...
You want all records containing that date, regardless of time? First, you
need to calculate today's date at midnight. Here is one way to do that (0
can be used to represent the seed date):
SELECT DATEADD(day,DATEDIFF(d,0,getdate()),0)
Now modify that expression to calculate the date 30 days ago at midinight,
and 29 days ago at midnight:
SELECT DATEADD(day,DATEDIFF(d,0,getdate())-30,0),
DATEADD(day,DATEDIFF(d,0,getdate())-29,0)
Now use those expressions in your Where clause to get all records between
those two dates, excluding the later date, like this:
WHERE TimeOfBooking >=
DATEADD(day,DATEDIFF(d,0,getdate())-30,0) AND
TimeOfBooking < DATEADD(day,DATEDIFF(d,0,getdate())-29,0)
Bob
Simon Gare wrote:
Sorry Bob,
Time of Booking contains Date and Time of vehicle required eg
21/1/2007 9:40:00. The query I am trying to build retrieves a count
of the bookings entered 30 days ago hence the
(SELECT Count(dbo.booking_form.TimeOfBooking) AS CountOfTimeOfBooking
FROM dbo.booking_form WHERE dbo.booking_form.TimeOfBooking =
DATEADD(day, -1, GetDate()) GROUP BY dbo.booking_form.TimeOfBooking")
Obviously the problem is as you described that the stored value is
date + time, can you sugeest an alternative?
Regards
Simon
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Simon Gare wrote: Hi all,
I am trying to retrieve a count of booking entries made 30 days ago, below is the end of the query I am having problems with.
dbo.booking_form.TimeOfBooking = DATEADD(day, -30, GetDate()) GROUP BY dbo.booking_form.TimeOfBooking")
When I use the = sign the error reads
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
for the entry on the page
(rsCash30("CountOfTimeOfBooking"))
But I know the record exists, also the query works when I use the signs < or or <all works ok but not with the = ??
Full SQL query reads
Set rsCash30 = myConn.Execute("SELECT Count(dbo.booking_form.TimeOfBooking) AS CountOfTimeOfBooking FROM dbo.booking_form WHERE dbo.booking_form.allocated = 'Completed' AND dbo.booking_form.CustomerID ='0' AND dbo.booking_form.TimeOfBooking = DATEADD(day, -30, GetDate()) GROUP BY dbo.booking_form.TimeOfBooking")
Regards
I am assuming SQL Server due to the presence of "dbo" in your sql
statement. Please don't make us guess. Always reveal the database
type and version when asking database-related questions.
You need to remember that the datetime datatype stores BOTH time AND
date. They are stored as paired integers: the firs integer contains
the number of days since the seed date, and the second contains the
number of milliseconds since midnight.
So, to see your problem, do this in QA or SSMS:
SELECT Top 10 DATEADD(day, -30, GetDate()) CompareDate,
TimeOfBooking FROM booking_form
Even this small sample should reveal that is is unlikely that
booking_form will ever be EQUAL to DATEADD(day, -30, GetDate()).
I am not sure what you are storing in TimeOfBooking. The name
suggests that you are attempting to store time only. I am not going
to waste time providing what may be an inappropriate solution based
on a guess. Tell us the datatype of TimeOfBooking and show us a few
examples of the data it contains.
Bob Barrorws
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so
I don't check it very often. If you must reply off-line, then remove
the "NO SPAM"
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Daniel Tonks |
last post by:
First, please excuse the fact that I'm a complete MySQL newbie.
My site used forum software that I wrote myself (in Perl) which, up until
now, has used flat files. This worked fine, however...
|
by: Eugfene |
last post by:
I have the following function in a html file:
function selectEdit(fileID, processCode, processID, fileName,fileDesc)
{
document.forms.recordID.value = fileID;
document.forms.processor.value =...
|
by: peashoe |
last post by:
I have an asp page that uses a calendar.js (pop-up) file to add an
exact date format in the text field (txtDDate). My problem is I need
some javascript that sets an alert that does not allow them...
|
by: Rob |
last post by:
Hi all,
I've got multiple sets of radio button that are dynamically created in
code and populated by a database query. The query returns about 20
recordsets with 3 radio buttons per recordset and...
|
by: george_Martinho |
last post by:
It seems that the ASP.NET Microsoft team didn't think about this!!
The profilemanager class has the following methods:
- DeleteInactiveProfiles. Enables you to delete all profiles older than
a...
| |
by: michele |
last post by:
Hi, I want to load a listbox with the date that are stored in a database
(mdb), the problem is when I retrieve the date it has a format like
"01/01/2006 0.00.00". In Access the date is stored as...
|
by: Darin |
last post by:
I have an applicatoin that works 100% perfect when running on a machine
setup for English (United States), but when I change it to Spanish
(Mexico), the dates start giving me fits.
THe reason is...
|
by: giandeo |
last post by:
Hello Experts.
I am unable to retrieve records base on a date. Could you please help me.
Here is my code for user to insert a date :
<form name="hello" method="post"...
|
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= |
last post by:
I have a C# logging assembly with a static constructor and methods that is
called from another C# Assembly that is used as a COM interface for a VB6
Application. Ideally I need to build a file...
|
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,...
|
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,...
| |
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...
|
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...
|
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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |