Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strvmarv/4fa868f31d354d191f3f29bd485d6cff to your computer and use it in GitHub Desktop.
Save strvmarv/4fa868f31d354d191f3f29bd485d6cff to your computer and use it in GitHub Desktop.
CREATE FUNCTION [dbo].[udf_GetDayOfTheYear] (@input DATETIME = NULL)
RETURNS SMALLINT AS
BEGIN
DECLARE @doty SMALLINT
IF (@input IS NULL)
BEGIN
SELECT @doty = DATEPART(dy, GETUTCDATE())
END
ELSE
BEGIN
SELECT @doty = DATEPART(dy, @input)
END
RETURN @doty
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment