Tag Archives: DATEPART

T-SQL – How to get the Financial Quarter details of a date field

declare @table table ( [Paid Date] date ) insert into @table values(‘20150102’),(‘20150512’),(‘20150830’),(‘20151231’),(‘20141230’) ;WITH Quarters AS ( SELECT Q = ‘Q1’, MonthBegin = 1, MonthEnd = 3 UNION SELECT Q = ‘Q2’, MonthBegin = 4, MonthEnd = 6 UNION SELECT Q … Continue reading

Posted in SQL | Tagged , , , , | 4 Comments

T-SQL to Display Weekends Between two Dates

Different ways to find the weekend between two given dates. The SQL requires @begindate and @endate paramteters to be entered in the below SQL Download T-SQL WeekendBetweenTwoValidDates DECLARE @beginDate Date=’20150101′, @endDate Date=’20150131′ DECLARE @Calendar Table (CalendarDate Date Primary key, IsWeekend Bit) … Continue reading

Posted in T-SQL | Tagged , , , , , , , , | 2 Comments