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

2007-04-12 (first published: )

465 reads

Blogs

Daily Coping 28 Oct 2021

By

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

The DBA as a helpdesk.

By

Every one and again you will see people asking What skill do you think...

What’s my MAC Address in a Command Prompt?–#SQLNewBlogger

By

Another post for me that is simple and hopefully serves as an example for...

Read the latest Blogs

Forums

Update table FirstName & LastName from Email addresses

By DaveBriCam

I have a table with three fields, FirstName, LastName and EmailAddress. The EmailAddress field...

SQL Instance Aliases - Urgent assistance needed please

By Brandie Tarvin

I have a migration problem. I cannot get my SQL Server instance aliases to...

Error connecting using AlwaysON Listener

By Arsh

Dear Friends, I have a 2-node Read-Scale Always ON Availability Group to which I...

Visit the forum

Ask SSC

SQL Server Q&A from the SQLServerCentral community

Get answers