Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 invalid parameter 1 specified for datediff

Author  Topic 

rajesha
Starting Member

36 Posts

Posted - 2003-10-15 : 02:50:43
I have created a stored proc

CREATE PROCEDURE [Usp_GetccScholarship] AS
BEGIN

SELECT
scholarship_id

FROM
Scholarship.dbo.Scholarship
WHERE
Datediff("M",
cast(Ltrim(Rtrim(cast(course_month_start as char)))+'/1/'+Ltrim(Rtrim(cast(course_year_start as char))) as datetime),
cast(Ltrim(Rtrim(cast(course_month_end as char)))+'/1/'+Ltrim(Rtrim(cast(course_year_end as char))) as datetime))<='24'
END
GO

when am clicking check syntax it shows syntax is successfull
but when am clicking ok ot shows Error 1023 :invalid parameter 1 specified for datediff

Can anybody help me to solve this problem?

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-10-15 : 02:59:55
Datediff accepts the following parameters for the datepart:

year, yy, yyyy
quarter, qq, q
month, mm, m
dayofyear, dy, y
day, dd, d
week, wk, ww
hour, hh
minute, mi, n
second, ss, s
millisecond, ms


Don't use quotes, and use lowercase.

Owais


Make it idiot proof and someone will make a better idiot
Go to Top of Page

rajesha
Starting Member

36 Posts

Posted - 2003-10-15 : 03:15:06
Thank you owasis it works.
Go to Top of Page

janellekessler
Starting Member

1 Post

Posted - 2015-01-05 : 19:30:13
I have a stored procedure which WORKS when I execute it from a query window, but fails with "invalid parameter 1 specified for datediff" when the stored procedure is called as a step in a sqlagent job. Code follows:
alter PROCEDURE [dbo].[sf_casesnotpublished]

AS
BEGIN

DECLARE @numberofcases AS INTEGER
DECLARE @rightnow AS DATE
DECLARE @maxdelay AS INTEGER

Insert into sf_cases_not_published
SELECT CURRENT_TIMESTAMP as rightnow,COUNT (ID) as numberofcases,
DateDiff(MINUTE,Min(CreateDate),current_timestamp) as maxdelay
FROM LGNCC_PUBLISHEDEVENT
WHERE (Status = 0) OR
(Status = 2)
END

I have tried everything for the datepart and it only does not work when executed by the server agent

janellekessler
Go to Top of Page
   

- Advertisement -