I have to calculate the difference from StartTime and EndTime. If the EndTime is less then 15 minutes that of StartTime I have to show an error.
CREATE PROCEDURE [Travel].[TravelRequirementValidate]
@Action char(1)
,@CallId int
,@PhaseId int
,@ShipId int
,@CallStartDate datetime
,@CallEndDate DATETIME
,@CallStartTime datetime
,@CallEndTime datetime
,@LanguageId int
,@SessionGroup nvarchar(100)
,@SessionPlace nvarchar(100)
,@ActiveFlg tinyint
,@WarningMessage nvarchar(300)=NULL output
,@Minutes int
as
if @Action in ('I','U')
begin
@Minutes=select DATEDIFF(@CallStartDate,@CallStartTime,@CallEndTime) from [Travel].[TravelRequirement]
if @Minutes<=15
begin
raiserror(3,11,1) --CallEndTime must be equals or higher than 15 minutes
return
end
end
This code doesn't work. I've got an error for the first parameter of DATEDIFF (invalid parameter 1 specified for datediff).
How can I fix my code?
EDIT
I changed @Minutes=select DATEDIFF(@CallStartDate,@CallStartTime,@CallEndTime) from [Travel].[TravelRequirement]
in
declare @Diff int
@Diff=select DATEDIFF(@Minutes,@CallStartTime,@CallEndTime) from [Travel].[TravelRequirement]
but I have the same error