This month's discount Comprehensive Database Performance Health Check · Testimonials
SQLAuthority with Pinal Dave
Home
  • Consulting
    • Health Check
  • Free Videos
  • All Articles
    • AI
    • SQL Performance
    • SQL Tips and Tricks
    • Interview Questions and Answers
    • SQL Puzzle
    • SQL Video
    • SQLAuthority News
    • Personal
  • Books
  • Consulting
A row of rain gauges holding different amounts of water

Grouping Dates Into Buckets With DATE_BUCKET

September 14, 2007
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Server, SQL Server 2022

DATE_BUCKET groups timestamps into hourly, weekly, and custom intervals, with an origin that determines where every boundary lands.

Read More
SQL SERVER - UDF - User Defined Function - Get Number of Days in Month

SQL SERVER – UDF – User Defined Function – Get Number of Days in Month

September 8, 2007
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts

A simple user defined function that returns the number of days in month for any date, with the leap year rule for February built in.

Read More
SQL SERVER - 2005 - Use of Non-deterministic Function in UDF - Find Day Difference Between Any Date and Today

SQL SERVER – 2005 – Use of Non-deterministic Function in UDF – Find Day Difference Between Any Date and Today

August 23, 2007
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Error Messages, SQL Function, SQL Scripts

I always thought a non-deterministic function was not allowed in a UDF, but GETDATE() works in SQL Server 2005. My UDF finds the day difference from today.

Read More
SQL SERVER - Find Monday of the Current Week

SQL SERVER – Find Monday of the Current Week

August 20, 2007
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Scripts, SQL Utility

Find Monday of the current week with one line of T-SQL: DATEADD and DATEDIFF with the week part and GETDATE() give you the date.

Read More
A paper calendar with the last day of the month circled in red.

SQL SERVER – Find Last Day of Any Month – Current Previous Next

August 18, 2007
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts, SQL Utility

Find the last day of any month with DATEADD and DATEDIFF. One script returns the last day of the previous, current and next month in SQL Server.

Read More
Wall covered with many vintage clocks showing different times

SQL SERVER – UDF – Function to Get Previous And Next Work Day – Exclude Saturday and Sunday

July 23, 2007
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts, SQL Server

Inspired by a ColdFusion post by Ben Nadel, here is the UDF I use to get the previous or Next Work Day for any date, skipping Saturday and Sunday.

Read More
SQL SERVER - UDF - Get the Day of the Week Function

SQL SERVER – UDF – Get the Day of the Week Function

July 23, 2007
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts, SQL Utility

Get the day of the week as a name in SQL Server: a UDF using DATEPART with CASE, plus the simpler DATENAME(dw, GETDATE()) a reader suggested.

Read More
Previous 1 … 24 25 26 27 28 29 Next
  • Books
  • Testimonials
  • Privacy Policy

© 2006 – 2026 All rights reserved. pinal @ SQLAuthority.com