syn_dean

Christmas "Monitoring" Gifts

Discussion created by syn_dean on Nov 12, 2013
Latest reply on Nov 26, 2013 by carl

Hey All.

Just wanted to put this out there for anyone that wants to add a little fun with the dashboards. We have added a special "Santa" monitor to our daily regular dashboard which counts the days until Christmas :smileyhappy:

 

good for the inner child in all of us. The SQL Query is simple enough and is shown below, feel free to make as mnay enhancements, changes etc...Just add the query into the DB datasource of a "TextBox" widget to output as a ($VAR).

 

--Declares the variables used

Declare @CurrentYear varchar(255);
Declare @daystilxmas int;

 

--Sets the varibale to just the year format, so it can determined for 2012,2013,2014 etc.
Set @CurrentYear = (SELECT DATENAME(year,GETDATE()))

 

--Sets the variable to count the days til the given date (Dec 25th) and today
set @daystilxmas = (select DATEDIFF(DAY, GETDATE(), @CurrentYear + '-12-25'))


--After 25th, the date diffference will become negative, so it will return 0 until the new year starts then from 1/1 will countdown again.   
IF @daystilxmas <= 0
    BEGIN
        SET @daystilxmas = 0
    END    
        

--Final output either 0 or a positive Integer

SELECT @daystilxmas

Outcomes