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: )

461 reads

Blogs

Using Write-Debug

By

I wrote a post about PoSh output recently, noting that in general we ought...

T-SQL Tuesday Retrospective #002: A Puzzling Situation

By

For the second T-SQL Tuesday ever — again, hosted by Adam Machanic — we...

Daily Coping 28 Oct 2020

By

I started to add a daily coping tip to the SQLServerCentral newsletter and to...

Read the latest Blogs

Forums

Index question

By Admingod

We have some indexes we have changed over the last few years to address...

Getting the top unique value by group

By David.Toews 95002

Alright, so I've been banging my head against the wall for a bit on...

table variable

By mtz676

deleted code resolved issue  

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers