first day of week 0 for that year (may belong to previous year) + number of weeks dateadd(ww, @weekNum + datediff(wk, 0, --1. First date of the year (week 0) dateadd(YEAR, datediff(year,0, getDate()),0) ),-1) -- -1 here because 1900-01-01 (day 0) was a ...
First and Last day of previous month from getdate() Fiscal Week Number Fixed Prefix Identity Column Fixing this TRIGGER Syntax Flashback query equavalant in Sql server Flatten a Parent-Child Hierarchy data Float Data Value and Scientific Notation float to datetime sql fn_dblog [Log Record...
The party was started by Adam Machanic (b|t) in December of 2009. This month’s T-SQL Tuesday’s topic is on Data Change. This is an important topic for me, since I’m about to create our first Data Warehouse at work. I’ve chosen to champion the companies who are using the ...
SYSDATETIME() AS Value UNION SELECT 2, 'YEAR', 'Beginning of this year', DATETRUNC(YEAR, SYSDATETIME()) UNION SELECT 3, 'MONTH', 'Beginning of this month', DATETRUNC(MONTH, SYSDATETIME()) UNION SELECT 4, 'DAY', 'Zero hour today', DATETRUNC(DAY, SYSDATETIME()) UNION SELECT 5, ...
months, we didn't have to think in terms of Years/Months. Because DATEDIFF also works for days, years, and even weeks, this same principle can be used to solve a lot of problems you may face in the future. For example, you can easily find the first day of the current month by ...
The key here is that we first dynamically create a "table" for the whole calendar year of 2016 and then query against this calendar table to find the first Wednesday for each month. -- find the 1st Wed of each month in 2016 -- solution 1 ...
Every SQL Server release has new capabilities that are exciting to some group of customers – sometimes a change is introduced to please sysadmins, sometimes it's for finance, sometimes it's for customers of other platforms, and sometimes it's for developers. Now that thefirst public preview ...
The second ParseLambda overload parses a lambda expression with a single unnamed parameter of a specified argumentType. This method corresponds to calling the first ParseLambda overload with a parameters argument containing a single ParameterExpression with an empty or null Name property. ...
Previous Row T-SQL (Part1/2) December 13, 2013 Calculating running totals, difference from the previous row are common problems. The tricky part to resolve these problems is to be able to link to the previous row. This first part of a two part series in which i discuss options to solve...
An integer literal consists of a sequence of digits. The type of an integer literal is the first of the types Int32, UInt32, Int64, or UInt64 that can represent the given value. An integer literal implicitly converts to any other numeric type provided the number is in the range of that...