473,382 Members | 1,407 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,382 software developers and data experts.

syntax help

I created a query in SQL that works fine but when i put it in the asp
code ( with dreamweaver ) i am getting an error when viewing the
page: expected end of statment...

rsBERProd_cmd.CommandText = "SELECT ISNULL(sum(case when type = 'BD'
and _dte = Convert(Char(8),GETDATE(),112) then qty else 0 end),0) as
Dayqty,ISNULL(sum(case when type = 'BD' and _dte between dateadd(dd,-
(day(GetDate())-1),GetDate()) and dateadd(dd,-(day(dateadd(mm,
1,GetDate()))),dateadd(mm,1,GetDate())) then qty else 0 end),0) as
Monthqty,ISNULL(sum(case when type = 'BD' and Year(_dte) =
Year(GetDate()) then qty else 0 end),0) as Yearqty,ISNULL(sum(case
when type = 'BD' and DatePart("ww", _dte)=DatePart("ww",
GetDate()) then qty else 0 end),0) as weekqty FROM
dbo.warehousebertransfer"

the problem i know is here: ("ww", _dte)=DatePart("ww",
GetDate())

the query needs those quotes so how can i get this to work? i tried
using just single quotes but then i get a sql error.... so can someone
help me make this work on the page?

Nov 13 '07 #1
2 2422
On Nov 13, 1:25 pm, Mangler <dwald...@aspdevil.comwrote:
I created a query in SQL that works fine but when i put it in the asp
code ( with dreamweaver ) i am getting an error when viewing the
page: expected end of statment...

rsBERProd_cmd.CommandText = "SELECT ISNULL(sum(case when type = 'BD'
and _dte = Convert(Char(8),GETDATE(),112) then qty else 0 end),0) as
Dayqty,ISNULL(sum(case when type = 'BD' and _dte between dateadd(dd,-
(day(GetDate())-1),GetDate()) and dateadd(dd,-(day(dateadd(mm,
1,GetDate()))),dateadd(mm,1,GetDate())) then qty else 0 end),0) as
Monthqty,ISNULL(sum(case when type = 'BD' and Year(_dte) =
Year(GetDate()) then qty else 0 end),0) as Yearqty,ISNULL(sum(case
when type = 'BD' and DatePart("ww", _dte)=DatePart("ww",
GetDate()) then qty else 0 end),0) as weekqty FROM
dbo.warehousebertransfer"

the problem i know is here: ("ww", _dte)=DatePart("ww",
GetDate())

the query needs those quotes so how can i get this to work? i tried
using just single quotes but then i get a sql error.... so can someone
help me make this work on the page?
nevermind, i just figured it out :)

DatePart(" & """ww"", _dte)=DatePart(" & """ww"", GetDate())

Nov 13 '07 #2
Mangler wrote:
On Nov 13, 1:25 pm, Mangler <dwald...@aspdevil.comwrote:
>I created a query in SQL that works fine but when i put it in the asp
code ( with dreamweaver ) i am getting an error when viewing the
page: expected end of statment...

rsBERProd_cmd.CommandText = "SELECT ISNULL(sum(case when type = 'BD'
and _dte = Convert(Char(8),GETDATE(),112) then qty else 0 end),0)
as Dayqty,ISNULL(sum(case when type = 'BD' and _dte between
dateadd(dd,- (day(GetDate())-1),GetDate()) and
dateadd(dd,-(day(dateadd(mm, 1,GetDate()))),dateadd(mm,1,GetDate()))
then qty else 0 end),0) as Monthqty,ISNULL(sum(case when type = 'BD'
and Year(_dte) = Year(GetDate()) then qty else 0 end),0) as
Yearqty,ISNULL(sum(case when type = 'BD' and DatePart("ww",
_dte)=DatePart("ww",
GetDate()) then qty else 0 end),0) as weekqty FROM
dbo.warehousebertransfer"

the problem i know is here: ("ww", _dte)=DatePart("ww",
GetDate())

the query needs those quotes so how can i get this to work? i tried
using just single quotes but then i get a sql error.... so can
someone help me make this work on the page?

nevermind, i just figured it out :)

DatePart(" & """ww"", _dte)=DatePart(" & """ww"", GetDate())
That works?? Given the use of GETDATE and ISNULL, this looks like T-SQL.
Unlike the VB/VBA/vbscript versions of the DATEPART,DATEADD and DATEDIFF
functions, T-SQL does not permit the use of quotes around the datepart
argument. It should simply be:

DatePart(ww, _dte)=DatePart(ww, GetDate())

See earlier in your sql statement where you used the dateadd function?
Same idea.

--
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.
Nov 13 '07 #3

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

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
22
by: Tuang | last post by:
I'm checking out Python as a candidate for replacing Perl as my "Swiss Army knife" tool. The longer I can remember the syntax for performing a task, the more likely I am to use it on the spot if...
4
by: Toonman | last post by:
I'm trying to use a couple of variables in a stored procedure. Things work fine when I hard code the data into the variables and also work fine when I use the variable in the WHERE clause and hard...
3
by: KevLow | last post by:
Hi, Hope some kind soul can help me out here.. I'm trying to programmatically modify the column headings of a crosstab query such that it can be dynamic based on user specified period (Month...
4
by: Bob hotmail.com> | last post by:
Everyone I have been spending weeks looking on the web for a good tutorial on how to use regular expressions and other methods to satisfy my craving for learning how to do FAST c-style syntax...
6
by: Scott Nixon | last post by:
New to Postgres 7.3 from 7.0. Am having some trouble with a query that worked in 7.0 but not in 7.3.....can't seem to figure out the syntax or find info about how to do this anywhere. ...
5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
13
by: usenet | last post by:
How and where can one find out about the basics of VB/Access2003 syntax? I am a died in the wool C/C++/Java Linux/Unix programmer and I am finding it difficult to understand the program format...
3
by: bearophileHUGS | last post by:
Probably you have already discussed this topic, but maybe you can stand touching it again briefly. Maybe properties aren't used so often to deserve a specific syntax, but I don't like their syntax...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.