Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

ASP query to SQL db
<% Datum = "1/1/2005"
Datum = cdate(datum)
Datum2 = datum + 9


Datum = Month(Datum) & "-" & Day(Datum) & "-" & Year(Datum)
Datum2 = Month(Datum2) & "-" & Day(Datum2) & "-" & Year(Datum2)

sql = "SELECT R_Reenval.NAAM, R_Reenval.Jaar, R_Reenval.Maand,
R_Reenval.Dag, R_Reenval.Reenval_Silo, Sum(Reenval_Silo) AS
SumOfReenval_Silo FROM R_Reenval WHERE ((R_Reenval.NAAM)='klerksdorp')
AND (R_Reenval.Datum Between " & cdate(Datum) & " And " & cdate(Datum2)
& ") Group By R_Reenval.NAAM, R_Reenval.Jaar, R_Reenval.Maand,
R_Reenval.Dag, R_Reenval.Reenval_Silo ORDER BY Jaar, Maand, Dag" %>

I am tryng to query some data according to dates...No matter hw I
change the format of the date variables, my recordset still returns no
data.

Any ideas, suggestions please. Any help will be gr8ly appreciated..thanx


Report this thread to moderator Post Follow-up to this message
Old Post
amatuer
10-24-06 11:38 PM


Re: ASP query to SQL db
This gives you a good overview of how you should pass datetime values and al
so recommendations on
how to construct searches on datetime ranges:
http://www.karaszi.com/SQLServer/info_datetime.asp

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www. solidqualitylearning
.com/


"amatuer" <njoosub@gmail.com> wrote in message
news:1161165428.268825.43060@i3g2000cwc.googlegroups.com...
> <% Datum = "1/1/2005"
> Datum = cdate(datum)
> Datum2 = datum + 9
>
>
> Datum = Month(Datum) & "-" & Day(Datum) & "-" & Year(Datum)
> Datum2 = Month(Datum2) & "-" & Day(Datum2) & "-" & Year(Datum2)
>
> sql = "SELECT R_Reenval.NAAM, R_Reenval.Jaar, R_Reenval.Maand,
> R_Reenval.Dag, R_Reenval.Reenval_Silo, Sum(Reenval_Silo) AS
> SumOfReenval_Silo FROM R_Reenval WHERE ((R_Reenval.NAAM)='klerksdorp')
> AND (R_Reenval.Datum Between " & cdate(Datum) & " And " & cdate(Datum2)
> & ") Group By R_Reenval.NAAM, R_Reenval.Jaar, R_Reenval.Maand,
> R_Reenval.Dag, R_Reenval.Reenval_Silo ORDER BY Jaar, Maand, Dag" %>
>
> I am tryng to query some data according to dates...No matter hw I
> change the format of the date variables, my recordset still returns no
> data.
>
> Any ideas, suggestions please. Any help will be gr8ly appreciated..thanx
>



Report this thread to moderator Post Follow-up to this message
Old Post
Tibor Karaszi
10-24-06 11:38 PM


Re: ASP query to SQL db
Thanx for the site Tibor. Contains alot of usefull and interesting
information, unfortunately none of them helpd solve my problem

Tibor Karaszi  wrote:[color=darkred
]
> This gives you a good overview of how you should pass datetime values and 
also recommendations on
> how to construct searches on datetime ranges:
> http://www.karaszi.com/SQLServer/info_datetime.asp
>
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www. solidqualitylearning
.com/
>
>
> "amatuer" <njoosub@gmail.com> wrote in message
> news:1161165428.268825.43060@i3g2000cwc.googlegroups.com... 


Report this thread to moderator Post Follow-up to this message
Old Post
amatuer
10-24-06 11:38 PM


Re: ASP query to SQL db
Run a Profiler trace so you see that SQL command submitted to SQL Server. Fo
rmat the datetime
strings so they are language neutral.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www. solidqualitylearning
.com/


"amatuer" <njoosub@gmail.com> wrote in message
news:1161168200.659185.119520@f16g2000cwb.googlegroups.com...
> Thanx for the site Tibor. Contains alot of usefull and interesting
> information, unfortunately none of them helpd solve my problem
>
> Tibor Karaszi wrote: 
>



Report this thread to moderator Post Follow-up to this message
Old Post
Tibor Karaszi
10-24-06 11:38 PM


Re: ASP query to SQL db
You need to add single quote mark around the date value in WHERE clause;
also, since Datun and Datum2 have been already formatted into a "mm-dd-yyyy"
format (hopefully, your SQL Server recognise date that way, not
"dd-mm-yyyy"), you do not need to convert it back to Date type with cdate():

"SEELCT ... WHERE...(R_Reenval.Datum Between '" & Datum & "' And '" & Datum2
& "')

"amatuer" <njoosub@gmail.com> wrote in message
news:1161165428.268825.43060@i3g2000cwc.googlegroups.com...
> <% Datum = "1/1/2005"
> Datum = cdate(datum)
> Datum2 = datum + 9
>
>
> Datum = Month(Datum) & "-" & Day(Datum) & "-" & Year(Datum)
> Datum2 = Month(Datum2) & "-" & Day(Datum2) & "-" & Year(Datum2)
>
> sql = "SELECT R_Reenval.NAAM, R_Reenval.Jaar, R_Reenval.Maand,
> R_Reenval.Dag, R_Reenval.Reenval_Silo, Sum(Reenval_Silo) AS
> SumOfReenval_Silo FROM R_Reenval WHERE ((R_Reenval.NAAM)='klerksdorp')
> AND (R_Reenval.Datum Between " & cdate(Datum) & " And " & cdate(Datum2)
> & ") Group By R_Reenval.NAAM, R_Reenval.Jaar, R_Reenval.Maand,
> R_Reenval.Dag, R_Reenval.Reenval_Silo ORDER BY Jaar, Maand, Dag" %>
>
> I am tryng to query some data according to dates...No matter hw I
> change the format of the date variables, my recordset still returns no
> data.
>
> Any ideas, suggestions please. Any help will be gr8ly appreciated..thanx
>



Report this thread to moderator Post Follow-up to this message
Old Post
Norman Yuan
10-24-06 11:38 PM


Re: ASP query to SQL db
amatuer  wrote:
> <% Datum = "1/1/2005"
> Datum = cdate(datum)
> Datum2 = datum + 9
>
>
> Datum = Month(Datum) & "-" & Day(Datum) & "-" & Year(Datum)
> Datum2 = Month(Datum2) & "-" & Day(Datum2) & "-" & Year(Datum2)
>
> sql = "SELECT R_Reenval.NAAM, R_Reenval.Jaar, R_Reenval.Maand,
> R_Reenval.Dag, R_Reenval.Reenval_Silo, Sum(Reenval_Silo) AS
> SumOfReenval_Silo FROM R_Reenval WHERE ((R_Reenval.NAAM)='klerksdorp')
> AND (R_Reenval.Datum Between " & cdate(Datum) & " And " & cdate(Datum2)
> & ") Group By R_Reenval.NAAM, R_Reenval.Jaar, R_Reenval.Maand,
> R_Reenval.Dag, R_Reenval.Reenval_Silo ORDER BY Jaar, Maand, Dag" %>
>
> I am tryng to query some data according to dates...No matter hw I
> change the format of the date variables, my recordset still returns no
> data.
>
> Any ideas, suggestions please. Any help will be gr8ly appreciated..thanx

Display the contents of the sql string somewhere on your page so that
you can see the SELECT statement that you've just built.  I think
you'll see that you're missing single quotes around your date values.


Report this thread to moderator Post Follow-up to this message
Old Post
Tracy McKibben
10-24-06 11:38 PM


Re: ASP query to SQL db
thanx norman, i was blind that day..lol


Norman Yuan  wrote:[color=darkred
]
> You need to add single quote mark around the date value in WHERE clause;
> also, since Datun and Datum2 have been already formatted into a "mm-dd-yyy
y"
> format (hopefully, your SQL Server recognise date that way, not
> "dd-mm-yyyy"), you do not need to convert it back to Date type with cdate(
):
>
> "SEELCT ... WHERE...(R_Reenval.Datum Between '" & Datum & "' And '" & Datu
m2
> & "')
>
> "amatuer" <njoosub@gmail.com> wrote in message
> news:1161165428.268825.43060@i3g2000cwc.googlegroups.com... 


Report this thread to moderator Post Follow-up to this message
Old Post
amatuer
10-31-06 05:15 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 08:37 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006