Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Re: SV: Re: Problems counting...


Message #1 by "Ken Schaefer" <ken@a...> on Tue, 9 Apr 2002 13:54:45 +1000
The problem is this: Your SQL query looks like:

SELECT count(*) as antal FROM Members WHERE date = 9/4/2002

Now 9 divided by 4 divided by 2002 is a very small number, and corresponds
to approximately 1/1/1900 (or something). Instead you need to surround the
date field with # marks to indicate that it is a date literal, not a
mathematical expression to be evaluated:

SELECT Count(*) AS antal FROM Members WHERE Date = #9/4/2002#

Also, you should look at this FAQ on dealing with dates and Access:
www.adopenstatic.com/faq/dateswithaccess.asp

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "SD-Studios" <info@s...>
Subject: [asp_databases] SV: Re: Problems counting...


: First, thanks Bharat, I will try that. Just in case I screw something up I
: think I'd better answer Kens questions.
:
: Currently I'm using Access =), and I'm not getting any error, but the
value
: just turns out 0 even though new members have registered today. I know you
: shouldnt use words like date for this purpose, but it wasnt me designing
the
: db, so I'll just have to blame the one that did it.. However thanks for
: helping out..

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Message #2 by "SD-Studios" <info@s...> on Mon, 8 Apr 2002 13:24:04 +0200
First, thanks Bharat, I will try that. Just in case I screw something up I
think I'd better answer Kens questions.

Currently I'm using Access =), and I'm not getting any error, but the value
just turns out 0 even though new members have registered today. I know you
shouldnt use words like date for this purpose, but it wasnt me designing the
db, so I'll just have to blame the one that did it.. However thanks for
helping out..
--
Martin Johansson,
CEO & Project Supervisor
SD-Studios
+46 (0)70-3003320
http://www.sd-studios.com


-----Ursprungligt meddelande-----
Från: Ken Schaefer [mailto:ken@a...]
Skickat: den 8 april 2002 02:56
Till: ASP Databases
Ämne: [asp_databases] Re: Problems counting...


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "SD-Studios" <info@s...>
Subject: [asp_databases] Problems counting...


: I've been trying to count the number of members registered today. Thought
: this would work... but it didn't.
:
: datum = date
:
: SQL = "SELECT count(*) as antal FROM Members WHERE date = " & datum
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And what is the problem?
Is there an error? Does the query not return the results you expect? What
database product are you using?

(Hints: words like "Date" are usually reserved - eg it is a VB/VBScript/VBA
reserved word, it's *not* a good idea to name variables, or tables, or
fields using reserved words)

Please help us help you!

Cheers
Ken






  Return to Index