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

What Agent Jobs are Running??

By

Do you run SQL Agent Jobs in your environment?  Do you know what is...

Unboxing SQL Clone 2020 for a PoC

By

When I got a new machine, I had SQL Clone on my old machine,...

Daily Coping 4 Aug 2020

By

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

Read the latest Blogs

Forums

Extended Events

By Michael L John

I have set up an extended event to capture the queries users may be...

Script logins and all permissions: no longer supported in SSMS generate script?

By Maxer

Okay, maybe I've just gone crazy but I was certain it used to be...

Recursive Select runs slow

By Soleya

Hello, I have a recursive Select that runs ultra slow. My test table has...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers