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.
Author |
Topic |
rajesha
Starting Member
36 Posts |
Posted - 2003-10-15 : 02:50:43
|
I have created a stored proc CREATE PROCEDURE [Usp_GetccScholarship] ASBEGINSELECT scholarship_id FROM Scholarship.dbo.ScholarshipWHERE 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'ENDGOwhen am clicking check syntax it shows syntax is successfullbut when am clicking ok ot shows Error 1023 :invalid parameter 1 specified for datediffCan 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 |
|
|
rajesha
Starting Member
36 Posts |
Posted - 2003-10-15 : 03:15:06
|
Thank you owasis it works. |
|
|
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]ASBEGINDECLARE @numberofcases AS INTEGERDECLARE @rightnow AS DATEDECLARE @maxdelay AS INTEGERInsert into sf_cases_not_publishedSELECT CURRENT_TIMESTAMP as rightnow,COUNT (ID) as numberofcases, DateDiff(MINUTE,Min(CreateDate),current_timestamp) as maxdelay FROM LGNCC_PUBLISHEDEVENTWHERE (Status = 0) OR (Status = 2) ENDI have tried everything for the datepart and it only does not work when executed by the server agentjanellekessler |
|
|
|
|
|
|
|