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
An unopened present with a red ribbon beside flat balloons and a party hat on a hall table

Calculating Age From a Date of Birth Correctly in T-SQL

August 7, 2009
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts, SQL Server

Use an explicit anniversary rule for calculating age in T-SQL, including February 29, years-months-days output and birthday lookups.

Read More
A wristwatch lying beside a torn-off paper calendar page on a wooden desk.

SQL SERVER – Get Time in Hour:Minute Format from a Datetime – Get Date Part Only from Datetime

August 6, 2009
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts, SQL Server

Get the time in Hour:Minute Format, or just the date, from a DATETIME with CONVERT styles 108 and 101, or with the TIME and DATE types in SQL Server 2008.

Read More
A SQL Server query in a window.

SQL SERVER – Find Last Date Time Updated for Any Table

May 9, 2009
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Scripts, SQL Table Operation

Want the last date time a table was updated without an UpdatedDate column? The sys.dm_db_index_usage_stats DMV shows it. A quick demo on AdventureWorks.

Read More
Gouache painting: on a kitchen counter one moka pot stands fully assembled from its three parts: base, funnel basket and top chamber

DATEFROMPARTS: Build Dates With Explicit Components

April 5, 2009
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Server

DATEFROMPARTS avoids ambiguous text assembly. Preserve year, month and day inputs while separating missing components from invalid calendar dates.

Read More
An open brass cash drawer holds undisturbed coin stacks as a shop shutter is lowered.

End-of-Day Balances From a Transaction Table

March 11, 2009
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Scripts, Temp Table

A transaction table stores movements, not balances. Collapse each day, run a total, fill the quiet days and dodge the midnight trap.

Read More
SQL Server 'WAITFOR' execution context in Visual Studio.

SQL SERVER – Time Delay While Running T-SQL Query – WAITFOR Introduction

January 3, 2009
Pinal Dave
SQL Tips and Tricks
Best Practices, SQL DateTime, SQL Scripts, SQL Utility

WAITFOR makes a T-SQL batch pause for a set time, or until a clock time, before the next statement runs. I show both uses with small examples.

Read More
A weather vane with a red rooster turning with the wind on a barn roof

Rolling Date Ranges Forward Without Hard-Coded Years

January 1, 2009
Pinal Dave
SQL Tips and Tricks
Execution Plan, SQL DateTime, SQL Server, SQL Stored Procedure

Replace hard-coded years with indexed date ranges for current periods, full months, year-to-date comparisons, and any requested year.

Read More
Previous 1 … 20 21 22 23 24 25 26 … 30 Next
  • Books
  • Testimonials
  • Privacy Policy

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