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 very long striped knitted scarf trailing from an armchair across the floor, needles still in the last row

Storing Durations and Summing Time Past 24 Hours

April 12, 2012
Pinal Dave
SQL Tips and Tricks
SQL Datatype, SQL DateTime, SQL Function, SQL Server

Use whole seconds for summing time beyond 24 hours, aggregate safely, format unlimited hours, and convert legacy time values.

Read More
Muddy carrots scrubbed in a farmhouse sink, a colander of clean carrots on the drainboard and peelings in a bowl.

Cleaning Messy Data With T-SQL

April 8, 2012
Pinal Dave
SQL Tips and Tricks
Data Observability, ETL, SQL DateTime, SQL Server, SQL String

Cleaning messy data With T-SQL means trimming text, parsing dates safely, and preserving rejected source rows for correction and replay.

Read More
SQL SERVER - Various Leap Year Logics

SQL SERVER – Various Leap Year Logics

March 3, 2012
Pinal Dave
SQL Tips and Tricks
SQL DateTime

Dividing by 4 is not enough to find a leap year. Readers shared various leap year logics in the comments, and here are the best of them.

Read More
Gouache painting of a database character beside a stopwatch

Leap Year in SQL Server: SQL in Sixty Seconds #004

February 29, 2012
Pinal Dave
SQL Video
SQL DateTime, SQL Function, SQL in Sixty Seconds, SQL Scripts

To find a leap year in SQL Server, ask EOMONTH for the last day of February. I tested the method against the divisibility rule for every year from 1 to 9999 and found no disagreement. The post also shows an inline function, the errors for invalid years and a one-line TRY_CONVERT test.

Read More
Gouache painting of a frog leaping across four lily pads on a pond, the last pad holding a red flower

Detect a Leap Year in T-SQL: Four Simple Ways

February 28, 2012
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts

Detecting a Leap Year in T-SQL takes one rule or one date trick. This post tests four ways on SQL Server 2025: the calendar rule, EOMONTH, TRY_CONVERT and DATEDIFF. It shows that all four agree on 209 years, explains the century years that trip people up, and answers how leap years affect date math.

Read More
A long wooden fence across a meadow with one red post marking the boundary between two fields.

Date Functions Quiz: What Does DATEDIFF Count?

January 28, 2012
Pinal Dave
SQL Puzzle
SQL Datatype, SQL DateTime, SQL Function

This Date Functions Quiz asks what DATEDIFF returns for two dates one day apart, when the unit is year. The answer is 1, because DATEDIFF counts boundaries crossed. A tested script shows an age calculation that works, plus DATETRUNC and EOMONTH.

Read More
A stone harbor wall at low tide with a dark band of seaweed marking the high water line, a coil of rope on the quay.

Watermarks for Incremental Extracts

December 19, 2011
Pinal Dave
SQL Tips and Tricks
Change Data Capture, Data Warehousing, ETL, SQL DateTime, SQL Server

Watermarks for incremental extracts need clear boundaries, durable checkpoints, and a plan for late updates, deletes, and missed rows.

Read More
Previous 1 … 15 16 17 18 19 20 21 … 30 Next
  • Books
  • Testimonials
  • Privacy Policy

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