Click here to Skip to main content
15,904,652 members
Home / Discussions / Database
   

Database

 
GeneralRe: Express Connection Problems Pin
Ed.Poore11-Nov-06 3:19
Ed.Poore11-Nov-06 3:19 
GeneralRe: Express Connection Problems Pin
Ed.Poore12-Nov-06 8:59
Ed.Poore12-Nov-06 8:59 
Questionautoincrement a column using C# Pin
kani9810-Nov-06 12:43
kani9810-Nov-06 12:43 
AnswerRe: autoincrement a column using C# Pin
Rob Graham10-Nov-06 14:24
Rob Graham10-Nov-06 14:24 
QuestionMDAC, JET and Windows Vista Pin
rajas10-Nov-06 7:47
rajas10-Nov-06 7:47 
QuestionInserting records.... Pin
dansoft9-Nov-06 21:41
dansoft9-Nov-06 21:41 
QuestionVariables in Proceedures Pin
oskardiazdeleon9-Nov-06 12:51
oskardiazdeleon9-Nov-06 12:51 
AnswerRe: Variables in Proceedures Pin
Colin Angus Mackay9-Nov-06 16:55
Colin Angus Mackay9-Nov-06 16:55 
oskardiazdeleon wrote:
i.e

datediff(@dateRange, getdate())=0


That's not a legal call to DATEDIFF[^] See the linked documentation for what you actually need.


oskardiazdeleon wrote:
Any Ideas?



CASE[^]


CASE @dateRange WHEN 'dd' THEN DATEDIFF(dd, GETDATE(), @someOtherDate) 
                WHEN 'ww' THEN DATEDIFF(ww, GETDATE(), @someOtherDate)
                WHEN 'yy' THEN DATEDIFF(yy, GETDATE(), @someOtherDate)
                ELSE 0 END


You could then potentially wrap this in a function[^], however, since GETDATE() is non-deterministic it isn't possible to do what you want, but you could always pass GETDATE() into the function.

e.g.

CREATE FUNCTION DateDifference(@dateRange CHAR(2), @startDate DATETIME, @endDate DATETIME)
RETURNS INT
AS
BEGIN
RETURN CASE @dateRange WHEN 'dd' THEN DATEDIFF(dd, @startDate, @endDate) 
                       WHEN 'ww' THEN DATEDIFF(ww, @startDate, @endDate)
                       WHEN 'yy' THEN DATEDIFF(yy, @startDate, @endDate)
                       ELSE 0 END
END

It can be called like this:

SELECT dbo.DateDifference(@dateRange, @someDate, GETDATE())


Does this help?


QuestionCreating a sql server data dictionary for our corporation? Pin
Goalie359-Nov-06 9:59
Goalie359-Nov-06 9:59 
AnswerRe: Creating a sql server data dictionary for our corporation? Pin
User 17164929-Nov-06 14:28
professionalUser 17164929-Nov-06 14:28 
QuestionCalling Procedures Pin
Dayekh9-Nov-06 3:07
Dayekh9-Nov-06 3:07 
AnswerRe: Calling Procedures Pin
Eric Dahlvang9-Nov-06 3:33
Eric Dahlvang9-Nov-06 3:33 
GeneralRe: Calling Procedures Pin
Dayekh9-Nov-06 3:52
Dayekh9-Nov-06 3:52 
GeneralRe: Calling Procedures Pin
indianet9-Nov-06 6:53
indianet9-Nov-06 6:53 
GeneralRe: Calling Procedures Pin
Eric Dahlvang9-Nov-06 9:25
Eric Dahlvang9-Nov-06 9:25 
GeneralRe: Calling Procedures Pin
Dayekh9-Nov-06 23:19
Dayekh9-Nov-06 23:19 
QuestionHow to merge two triggers to one Pin
andreas_6359-Nov-06 1:55
andreas_6359-Nov-06 1:55 
AnswerRe: How to merge two triggers to one Pin
Eric Dahlvang9-Nov-06 3:11
Eric Dahlvang9-Nov-06 3:11 
GeneralRe: How to merge two triggers to one Pin
andreas_6359-Nov-06 4:03
andreas_6359-Nov-06 4:03 
GeneralRe: How to merge two triggers to one Pin
Eric Dahlvang9-Nov-06 10:09
Eric Dahlvang9-Nov-06 10:09 
QuestionSign-On Question from Extreme Novice Pin
Jethro639-Nov-06 1:50
Jethro639-Nov-06 1:50 
AnswerRe: Sign-On Question from Extreme Novice Pin
Mike Dimmick9-Nov-06 6:07
Mike Dimmick9-Nov-06 6:07 
GeneralRe: Sign-On Question from Extreme Novice Pin
Jethro639-Nov-06 7:50
Jethro639-Nov-06 7:50 
Questionimage insertion in sqlserver Pin
yuvachandra9-Nov-06 1:13
yuvachandra9-Nov-06 1:13 
AnswerRe: image insertion in sqlserver Pin
saqib829-Nov-06 20:56
saqib829-Nov-06 20:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.