Search results
1 sty 2012 · The best way is to extract the current year then use concatenation like this : SELECT CONCAT(year(now()), '-01-01') as start, -- fist day of current year. CONCAT(year(now()), '-31-12') as end; -- last day of current year. That gives you : start : 2020-01-01 and end : 2020-31-12 in date format.
Here are all the three queries for you to try out: -- First and Last Day of Year. SELECT DATEADD (yy, DATEDIFF (yy, 0, GETDATE ()),0) as 'First Day of Year'. SELECT DATEADD (dd, -1, DATEADD (yy, DATEDIFF (yy,0,GETDATE ()) + 1, 0)) as 'Last Day of the Year'. -- First and Last Day of Quarter.
27 cze 2019 · Learn SQL Server date functions to get beginning and ending periods such as first day of the week, month, quarter, year, and dynamic end dates.
20 lip 2013 · We can use a query like below to get Quarter’s Start and End Date for a given date. DECLARE @AnyDate DATETIME SET @AnyDate = GETDATE() SELECT @AnyDate AS 'Input Date', DATEADD(q, DATEDIFF(q, 0, @AnyDate), 0) AS 'Quarter Start Date', DATEADD(d, -1, DATEADD(q, DATEDIFF(q, 0, @AnyDate) + 1, 0)) AS 'Quarter End Date'
29 kwi 2020 · These are simple scalar functions that take a single date parameter, and return the date for the start of the calendar year and the end of the calendar year that contain the date provided. You can use our tools as a set or as a great example of how to write functions like these. Find out more.
ALTER TABLE [DBName].[dbo].[TestDate] ADD End_Date as DATEADD(D, 7 * (Duration / 5) -- Business weeks as calendar days + CHOOSE(DATEPART(WEEKDAY, StartDate),-2,0,0,0,0,0,-1) -- Move weekend start to Friday, if needed + (Duration % 5) -- Day outside of full business weeks +IIF(DATEPART(dw, DATEADD(D, CHOOSE(DATEPART(WEEKDAY, StartDate),-2,0,0,0 ...
20 kwi 2017 · SELECT p_begin.ProcessOrder, p_begin.ProcessDate as ProcessBegin, DateAdd(day, -1, p_end.ProcessDate) as ProcessEnd FROM Process p_begin LEFT OUTER JOIN Process p_end ON p_end.ProcessOrder = p_begin.ProcessOrder + 1