Following User Defined Function (UDF) returns the numbers of days in month. It is very simple yet very powerful and full proof UDF. CREATE FUNCTION [dbo].[udf_GetNumDaysInMonth] ( @myDateTime DATETIME ) RETURNS INT AS BEGIN DECLARE @rtDate INT SET @rtDate = CASE WHEN MONTH(@myDateTime) IN (1, 3, 5, 7, 8, 10, 12) THEN 31 WHEN MONTH(@myDateTime)… Continue Reading...
Source: SQL SERVER – UDF – User Defined Function – Get Number of Days in Month | Journey to SQL Authority with Pinal Dave
No comments:
Post a Comment