2011 BI and Data Trend Predictions by Deloitte

January 10th, 2012 / No Comments » / by admin

I realize it is already 2012 but since the current year’s report has not been released yet I thought this finding still applies. The 2011 Deloitte Consulting Annual Technology Trends report  has been released and not surprisingly, amongst the top ten trends identified (based on their potential business impact over the next 18 months), data visualization and real analytics found their way into number one and six. The report has been compiled based on input from clients, analysts, alliances and Deloitte’s network of academic leader and categorized into (Re)Emerging Enablers (trends that many CIOs have spent time, thought and resources on in the past) and Disruptive Deployments (trends that simply present significant new opportunities for the business).

Continue Reading This Post

Tags: ,

SQL – Calculating number of days in a month

January 6th, 2012 / No Comments » / by admin

Here is a little function which I found myself using a number of times (particularly to calculate averages over the length of a specific month) which calculates number of days in any given month. All you need to do, is to provider it with a datetime input parameter to return number of days as an integer.

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[fun_GetDaysInMonth] (@pDate DATETIME )
RETURNS INT
AS
BEGIN
    RETURN CASE WHEN MONTH(@pDate) IN (1, 3, 5, 7, 8, 10, 12) THEN 31
                WHEN MONTH(@pDate) IN (4, 6, 9, 11) THEN 30
                ELSE CASE WHEN (YEAR(@pDate) % 4    = 0 AND
                                YEAR(@pDate) % 100 != 0) OR
                               (YEAR(@pDate) % 400  = 0)
                          THEN 29
                          ELSE 28
                     END
           END
END
GO

And here is the SQL code and results from the actual implementation. All we need to do is call the function, here using ‘GETDATE()’ as an input parameter and repeating it a few times using ‘DATEADD’ function to generate few more months in a row.

------------------------------------------------------------------------
--	  					DAYS IN JANUARY 2012							|
------------------------------------------------------------------------
SELECT convert (nvarchar (10), datename(month,'2012/01/01')) + ' '
+ convert (nvarchar (10), datepart(year,'2012/01/01')) as [Month/Year],
dbo.fun_GetDaysInMonth (GETDATE()) as Number_of_Days;

------------------------------------------------------------------------
--						DAYS IN FEBRUARY 2012							|
------------------------------------------------------------------------
SELECT convert (nvarchar (10), datename(month,'2012/02/01')) + ' '
+ convert (nvarchar (10), datepart(year,'2012/02/01')) as [Month/Year],
dbo.fun_GetDaysInMonth (dateadd(month,1,GETDATE())) as Number_of_Days;

------------------------------------------------------------------------
--						DAYS IN MARCH 2012								|
------------------------------------------------------------------------
SELECT convert (nvarchar (10), datename(month,'2012/03/01')) + ' '
+ convert (nvarchar (10), datepart(year,'2012/03/01')) as [Month/Year],
dbo.fun_GetDaysInMonth (dateadd(month,2,GETDATE())) as Number_of_Days;

------------------------------------------------------------------------
--						DAYS IN APRIL 2012								|
------------------------------------------------------------------------
SELECT convert (nvarchar (10), datename(month,'2012/04/01')) + ' '
+ convert (nvarchar (10), datepart(year,'2012/04/01')) as [Month/Year],
dbo.fun_GetDaysInMonth (dateadd(month,3,GETDATE())) as Number_of_Days;
GO

Tags: ,