473,569 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.C ommandText = "SELECT ISNULL(sum(case when type = 'BD'
and _dte = Convert(Char(8) ,GETDATE(),112) then qty else 0 end),0) as
Dayqty,ISNULL(s um(case when type = 'BD' and _dte between dateadd(dd,-
(day(GetDate())-1),GetDate()) and dateadd(dd,-(day(dateadd(mm ,
1,GetDate()))), dateadd(mm,1,Ge tDate())) 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.warehousebe rtransfer"

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 2429
On Nov 13, 1:25 pm, Mangler <dwald...@aspde vil.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.C ommandText = "SELECT ISNULL(sum(case when type = 'BD'
and _dte = Convert(Char(8) ,GETDATE(),112) then qty else 0 end),0) as
Dayqty,ISNULL(s um(case when type = 'BD' and _dte between dateadd(dd,-
(day(GetDate())-1),GetDate()) and dateadd(dd,-(day(dateadd(mm ,
1,GetDate()))), dateadd(mm,1,Ge tDate())) 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.warehousebe rtransfer"

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...@aspde vil.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(s um(case when type = 'BD' and _dte between
dateadd(dd,- (day(GetDate())-1),GetDate()) and
dateadd(dd,-(day(dateadd(mm , 1,GetDate()))), dateadd(mm,1,Ge tDate()))
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.warehouseb ertransfer"

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,DATEAD D 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
33516
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 capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it...
22
3404
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 the need arises. If I have to go off and look it up, as I increasingly have to do with Perl's ever hairier syntax, I'm more likely to just skip it,...
4
2843
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 code data for the other variable. So, I think I have a syntax problem when trying to use "FrontPage.@FrontpageProduct" as seen in my example code...
3
3098
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 Year to Month Year) So far i have tried to use the following code: //
4
7601
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 highlighting in C# but I have yet to find anything useful I know there are people at MS that know this stuff like the front of their hand and I know...
6
6298
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. Consider for the following query: - 'number' is an integer - 'procedures' is the table name - 'date' is a timestamp
5
4484
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 including the -q64 option in xlC compiler. And we are able to link all these libraries to one of the main applications and generate an executable....
3
16208
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 strange error. In your experience, where I should looking to find the real error? Surely the sintax of glut is correct... gcc.exe -c...
13
3015
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 for accessing objects, controls, etc. in VB/Access2003. In particular where will I find explanations of:- Actions, Functions, Methods,...
3
1593
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 much. Here I show some alternative solutions that work with the current Python, followed by a syntax idea, that may be better fit for Python 3.0...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7968
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.