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

482 reads

Blogs

SQL Data Pipelines: The Ultimate Guide to Streamlining Your Data Flow

By

Want to build a data analytics foundation that transforms raw data into valuable business...

Using SQL Compare in Read-Only Databases

By

Recently a customer asked if SQL Compare and SQL Data Compare can be used...

T-SQL Tuesday #179 Roundup: The Data Detective Toolkit

By

Earlier this month, I hosted the monthly T-SQL Tuesday invitation in which I asked,...

Read the latest Blogs

Forums

Date Type ETL Question

By Coffee_&_SQL

I'm not sure that I'm posting this in the right section, so please mods...

Possible oddity in msdb.dbo.backupset

By richardmgreen1

Hi all   I've written a script to keep track of how long backups...

Operand data type varchar is invalid for sum operator

By yrstruly

I have this view [dbo].[Asset Metrics - Client(Rama -Client-Test)], which makes use of multiple...

Visit the forum

Question of the Day

Data Migration Assistant Sources

In the current (Sep 2024) Data Migration Assistant, what are the possible sources for on-premises SQL Server instances?

See possible answers