T-SQL equivalent for NEXT_DAY() of ORACLE


I thought of creating a simple function for this operation, in T-SQL.

Function Name: Next_Day

Input Params: @FromDate – Date from which you wish to get the next day; @DayNumber – Day of week for which you wish to get the next day (6=>Saturday, 7=>Sunday)

Operation: SELECT dbo.Next_Day(GETDATE(),6) //Returns the next Saturday (6) from today

Function: Function body

CREATE FUNCTION dbo.Next_Day
(
@FromDate DATETIME,
@DayNumber INT
)
RETURNS DATETIME
AS
BEGIN

DECLARE @CurrentDate AS DATETIME
DECLARE @DayOfWeek AS TINYINT

SELECT @DayOfWeek = DATEPART(WEEKDAY, @FromDate)
SELECT @DayNumber = @DayNumber + 1

IF (@DayOfWeek < @DayNumber) — Not equal to Thursday
BEGIN
SELECT @CurrentDate = (@FromDate + (@DayNumber-@DayOfWeek))
END
ELSE
BEGIN
SELECT @CurrentDate = (@FromDate + ((@DayNumber+2)-(@DayOfWeek-@DayNumber)))
END

RETURN @CurrentDate
END

GO

–SELECT dbo.Next_Day(‘2011-04-05’,6) //2011-04-09 11:46:38.867 – next saturday after 5th April 2011

Run the above SQL statement and you get your function.

Reference CodeLink

 

How to remove the dotted outline when you click on button or anchor tag


It is quite common fact that due to paddings, we tend to blow the control to larger sizes. Say a menu item, which is a simple anchor tag, inside an ordered list; you will blow the anchor to such a level that on click of it, there appears an outline with dotted line, which looks awkward.

The fix for this:

a { outline:none; }

Bear in mind that this styling literally uses the “outline” CSS property. Outline is very similar to the “border” property, with two important differences:

  • Outline goes around the entire object (much like using just “border”), but you may not be specific about sides. “Outline-left” does not exist.
  • Outline value is not a part of the box model. Border is calculated into the total width of the box, whereas outline is not. This is important so that layouts don’t get bumped around when the outline is applied and removed.