GetTheMinutes

HOW To Get the Minutes from a Date/Time
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

/*
   GetTheMinute
   Syntax: SELECT dbo.@TheMinuteIs(GETDATE())
*/

CREATE FUNCTION [dbo].[GetTheMinute] (@dtDateParam DateTime)
RETURNS int
AS
BEGIN
   DECLARE @TheMinuteIs int
   IF ISDATE(@dtDateParam)>0
      BEGIN           
        SELECT @TheMinuteIs = CAST(DATEPART(MINUTE, @dtDateParam) as int)
      END
   ELSE
      BEGIN
		SET @TheMinuteIs = 0
      END
   RETURN(@TheMinuteIs)
END
GO
 

Add Feedback