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

478 reads

Blogs

Migrating from EverNote to Joplin

By

Recently I got a message that my Evernote subscription was going up. It’s been...

Using Data Masker on Chinese Surnames

By

A customer had a question recently on masking Chinese characters. I thought that was...

A New Word: Looseleft

By

looseleft – the feeling of loss upon finishing a good book, sensing the weight...

Read the latest Blogs

Forums

How can I show the last opening period for each project in my project dimension

By casagrandi

I have two attributes hierarchies in my dimension [Dim Project]: Project Code Opening date...

Upgrading from 2016 to 2019 with Encryption

By Richard Warr

Hi, I have a few AWS EC2 instances currently running SQL Server 2016. I'd...

NOT LIKE Alternatives in WHERE clause

By BOR15K

Hello, I need help to improve an existing (hence I cannot change table's structure...

Visit the forum

Ask SSC Logo Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers