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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 invalid parameter 1 specified for datediff
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rajesha
Starting Member

36 Posts

Posted - 10/15/2003 :  02:50:43  Show Profile  Reply with Quote
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

United Arab Emirates
1456 Posts

Posted - 10/15/2003 :  02:59:55  Show Profile  Visit mohdowais's Homepage  Reply with Quote
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 - 10/15/2003 :  03:15:06  Show Profile  Reply with Quote
Thank you owasis it works.
Go to Top of Page

janellekessler
Starting Member

USA
1 Posts

Posted - 01/05/2015 :  19:30:13  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000