Showing posts from April, 2013

Handy Date Functions

These date functions are especially useful for BI and reporting type scenarios. Used properly they can simply SQL code making it much, much easier to read. Used properly they can also make SQL queries perform better!!!First let’s install the date functions by running the following code snippets:1. The first day of the month 1:SET ANSI_NULLS ON 2:GO 3:SET QUOTED_IDENTIFIER ON 4:GO 5:-- ============================================= 6:-- Author: William Brown 7:-- Create date: 2013-04-29 8:-- Description: Return the first day of the month 9:-- For more information check out 10:-- 11:-- ============================================= 12:CREATEFUNCTION fn_FirstDateOfMonth(@date DATETIME) 13:RETURNSDATE 14:AS 15:BEGIN 16: 17: