UDF for date ranges around a given date (updated)

UDF - SQL 2000 and higherThis function returns an 18 row table of date ranges around a given date.The ranges are: Day, Week (Sunday to Saturday), Month, Quarter, Half Year, Year.For each range there are 3 values: Previous, Same and NextExample of usage:Joined to an orders table:Select r.period, count(o.order_id)from orders oinner join dbo.ufn_date_ranges('2003-04-01') ron o.order_date […]

2007-04-12 (first published: )

460 reads

Blogs

What the ???? T-SQL Tuesday #120

By

Hey, it’s T-SQL Tuesday again! I almost forgot about it what with Summit and...

First Time Speaking at PASS Summit

By

This week, I filmed my experience as a first time speaker at PASS Summit...

Azure SQL Best Practices?

By

A way to enforce good practice and standards is by Azure Policy. As stated...

Read the latest Blogs

Forums

SQL View - Pivot

By bbranco

I have the following data in a table, its pricing for items, so if...

does WITH (NOLOCK) hint in Select statement really make a difference?

By VoldemarG

In any regular Select query joining a few tables like below, does using this...

Query

By jsshivalik

Hi Table 1 AccountId Name 1101 aaaa 1701 bbbb Table 2 TransId Account Debit...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers