Search results
select min(period) as period, MIN(date), MAX(date) from (select t.*, (select min(date) from t t2 where t2.period <> t.period and t2.date > t.date) as nextp from t ) t group by nextp The inner subquery gets the date of the next period.
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.
Also if the actual_date is having value that value is saved as end_date. Example : Start_date = 18/05/2020 , Duration : 10. So the End_date should be calculated by excluding 23/05/2020 and 24/05/2020. I had tried different ways to archive this. The below is the alter query for the column end_date.
24 kwi 2023 · This SQL tutorial illustrates some of the most common techniques for searching between two date values in SQL, including using the BETWEEN operator, the greater than (>) and less than (<) operators, and the DATEPART () function.
13 sty 2021 · List All Dates – Including Start and End Date DECLARE @StartDate DATE, @EndDate DATE SELECT @StartDate = '2021-11-01', @EndDate = '2021-12-01'; WITH ListDates(AllDates) AS ( SELECT @StartDate AS DATE UNION ALL SELECT DATEADD(DAY,1,AllDates) FROM ListDates WHERE AllDates < @EndDate) SELECT AllDates FROM ListDates GO
17 wrz 2013 · select cast(dateadd(m,3*(number-1),dateadd(yyyy,datediff(yyyy,0,getdate()),0)) as date) [qt start date] , cast(dateadd(d,-1,dateadd(m,3*(number),dateadd(yyyy,datediff(yyyy,0,getdate()),0))) as date) [qt end date] , number as [quarter name] from master..spt_values where type='p' and number between 1 and 4
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'