Technical Article

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 […]

You rated this post out of 5. Change rating

2007-04-12 (first published: )

479 reads

Blogs

How Long Will It Take to Learn SQL? The Truth Might Surprise You

By

In today's data-driven world, SQL (Structured Query Language) is a blazing-hot skill. It's your...

Flying Halfway Around the World to Australia

By

I leave tonight for Australia. I was in London 3 days ago, so this...

Dealing with Change – Two Resources

By

As I look at the state of information technology today, I see one constant:...

Read the latest Blogs

Forums

SSIS Execution Error

By Wecks

I am no SSIS expert and am struggling here I am hoping some of...

Pivot query

By Roust_m

Hi, I have the following table: CREATE TABLE [dbo].[UnitProdFinal]( [YearMonth] [int] NULL, [SerialNumber] [varchar](50)...

Table with FK(s) to other columns within the table

By BOR15K

Hello All, I have recently joined a project, where main, core tables with millions...

Visit the forum

Question of the Day

Using Table Hints in a Query

How many table hints can I include in a query?  

See possible answers