I'm trying to change a date from 2005-10-01 00:00:00.000 to Oct-05.
I would need this to work for any month. How can I do this?
I'm using SQL Server 2005.
Thanks!
We have a report where we allow the user to specify a date range and pull all of the purchase orders pulled between the specified dates.
Well, there is a problem with the report.
The code is like this:
WHERE CreatedDate BETWEEN @begindate AND @enddate
If the begin date is 2011-06-29 and the...
I am pulling from a few temp tables and am not sure how to join them so I get the right results. The goal is, in essence, to make the following calculation:
InventoryCount1+PurchaseOrdersMadeBetweenCount1and2-InventoryCount2=InventoryUsage
Tables:
1) Inventory Counts Temp Table containing...
Hello again :)
Thanks not in small part to the assistance of you fine people, I have my 6-pages of code working. Now I'm working on optimizing it. I've knocked the run time down from 11 seconds to 6, but I know of a couple other places I could speed it up.
One is with filtering inventory...
SQL Server 2005 is saying that Wk1Usage.Wk1Usage in the update statement for my temp table can't be bound, but I don't see any problems with my syntax. Help? :S The subquery in the update runs flawlessly.
CREATE TABLE #temp_usage
(
SiteID CHAR(10),
InvtID CHAR(30),
Wk1Usage FLOAT...
Maybe I'm thinking of this wrongly, but I have a situation where, if the values in 6 different columns are ALL null, I don't want to display that row.
For example, column 1 is InventoryID, then columns 2-7 will be Week1Quantity, Week1Quantity, Week3Quantity, etc.
If all 6 weeks of quantity...
If, in my select, I have something like SUM(Quantity) as TotalQty
...Then how do I refer to that in the where clause?
I want to say...
WHERE TotalQty IS NOT NULL
...but it doesn't recognize the alias, so I try...
WHERE sum(Quantity) IS NOT NULL
...but it won't take that either.
Workarounds?
I'm writing a complicated script requiring a lot of logic, to the point that I can't make all of the calculations in a single statement. I got to the point where I had something like 5 nested subqueries, SQL wasn't liking it, and my coworker said I was overcomplicating it (the logic of the...
Hello :) What would be the best way to implement this where statement pseudocode with proper syntax? Basically, I'm trying to pull dates out of a temp table I've created using subqueries
WHERE CreatedDateTime BETWEEN (SELECT StartDate FROM #temp) AND (SELECT EndDate FROM #temp)
The...
ntaxTerror (TechnicalUser) Jan 6, 2011
I have a CASE statement where I'm using MAX in my WHEN and it's failing the conditions of the WHEN because the date doesn't fall within the specified range, when it should.
Looking at the date output, it pulls a date of 2007-01-09 when it should pull...
I'm writing a report that will go back from the current date and break it up into weekly periods, so I wanted to use DATEADD to achieve this by doing something like...
DECLARE @CurrDate as TimeStamp
SELECT CASE WHEN CreatedDate BETWEEN DATEADD(D, -7, @CurrDate) and DATEADD (D, 1, @CurrDate)...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.