Viewing 15 posts - 46 through 60 (of 355 total)
Can there only ever be be one row with a NULL ChangeDate, with this row belonging to the most recent group?
If this is not the case, then how can you...
November 9, 2010 at 3:02 am
CREATE TABLE #MyTempTable (date_field datetime)
INSERT INTO #MyTempTable(date_field)
SELECT '2010-06-24T18:19:00.000' UNION ALL
SELECT '2010-06-20T01:50:00.000'
UPDATE #MyTempTable
SET date_field = DATEADD(day, DATEDIFF(day, '1753-01-01T00:00:00.000', date_field), '1753-01-02T06:59:00.000')
WHERE DATEPART(hour, date_field) >= 7
November 3, 2010 at 10:28 am
Averaging a date column is a fairly unusual thing to want to do, but if you really want to do this, it is achievable by first converting the datetime to...
November 2, 2010 at 12:04 pm
Amusingly, any sequence of unary operators before an integer (as long as two dashes together are avoided) seems to be valid in TSQL:
DECLARE @a int
October 29, 2010 at 7:05 am
There is a standard mathematical expression for the sum of all integers from 1 to N.
Sum(R) {R = 1..N} = N * (N + 1) / 2
So you could just...
October 28, 2010 at 6:00 am
It's a simple change to your existing datetime expressions:
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 15, 0)
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 12, 0)
October 28, 2010 at 5:41 am
22800 = 1900 * 12
so
DATEADD(MONTH, 12 * @Year + number - 22801, 6)
is equivalent to
DATEADD(MONTH, 12 * (@Year - 1900) + number - 1, 6)
but saves...
October 27, 2010 at 4:46 pm
Here is your test data in a readily consumable form, i.e. a CREATE TABLE statement and an INSERT statement. Supplying test data in this form will encourage people to assist...
October 27, 2010 at 4:33 pm
Here's another solution using PATINDEX and STUFF.
EDIT: Just noticed my solution was identical to Chris Morris' so have removed it.
October 27, 2010 at 2:28 pm
Does this return anything on your database?
select payrolldate,
Sunday = dateadd(dd, ((datediff(dd, '17530107', payrolldate)/7)*7)+7, '17530107')
from payroll
October 26, 2010 at 10:16 am
You have a GROUP BY clause but since you have no aggregate functions its only effect is to eliminate duplicate rows.
It would help if you could describe what you trying...
October 21, 2010 at 8:23 am
How do you define the sequential order of rows in this table?
Is there a suitable datetime column or an incrementing integer column?
October 21, 2010 at 6:59 am
The Dixie Flatline (10/18/2010)
--------------------------------------------------------------------------------
I once heard two brothers argue (inconclusively) about whether or not black and white were colors. Opinions anyone?
Black is a colour in the same way that...
October 18, 2010 at 4:52 pm
You are probably not getting the results you are expecting because AND comes above OR in the operator precedence table. I've added brackets to show how your WHERE clause is...
October 18, 2010 at 4:40 pm
UNPIVOT does precisely what you're looking for.
SELECT [EmployeeNumber], [Security], [Level]
FROM [dbo].[GblSecurityMain]
UNPIVOT (
[Level] FOR [Security]
IN ([Development], [Time], [Inventory], [Renewal], [Support], [Results])
)...
October 18, 2010 at 3:12 pm
Viewing 15 posts - 46 through 60 (of 355 total)