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
Gouache painting of a plain stone sundial next to a sand hourglass with a vermilion frame

Current Timestamp in Python and SQL: One Format, Two Tools

September 23, 2021
Pinal Dave
SQL Tips and Tricks
Python, SQL DateTime, SQL Server

To get the current timestamp in Python, import datetime, call now and format the result with strftime. This post prints the same date and time in Python and in T-SQL, compares the two clocks, and shows how to ask for UTC in both.

Read More
Work strips, paired covered intervals and a separate closure marker form a defined schedule.

SQL SERVER – Find Business Days Between Dates

July 5, 2021
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Scripts, SQL Server

Business Days Between Dates require a defined calendar and endpoint rule. This example counts inclusive Monday-to-Friday dates for July 2021.

Read More
cultures FORMAT

SQL SERVER – Display Dates in Different cultures FORMAT

May 31, 2021
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Scripts, SQL Server

Today we are going to learn a very simple and interesting concept used very little. It is about how to Display Dates in Different cultures FORMAT.

Read More
Gouache painting of a shelf of preserve jars with one empty jar and a bare gap holding a vermilion ribbon

Convert Empty String to NULL Date in SQL Server: Use NULLIF

May 6, 2021
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL NULL, SQL Scripts

To convert empty string to NULL in a date column, wrap the text in NULLIF before you cast it. A plain CAST returns 1900-01-01 and hides the problem. This post tests five expressions on six text values, including a real 1900 date, a run of spaces and a tab, and shows which ones stay correct.

Read More
Gouache painting of two identical windows showing the same garden at night, with a small potted plant between them

AT TIME ZONE Twice: Convert UTC to Local Time in SQL Server

February 22, 2021
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts, SQL Server

AT TIME ZONE twice converts UTC to local time in SQL Server. The first use labels a plain value as UTC and the second converts it. A demo shows the common one step mistake, stores in three cities, and the missing and repeated hours of daylight saving.

Read More
A tall stack of pancakes on one plate and a fresh plate with a single pancake, a hand adding the next one.

Running Totals That Reset Every Month

February 5, 2021
Pinal Dave
SQL Tips and Tricks
SQL DateTime, SQL Function, SQL Scripts, SQL Server

Calculate running totals that reset by calendar month, customer, or fiscal period, using stable ordering and explicit ROWS frames.

Read More
Gouache painting of a line of stepping stones across a pond with the last one vermilion

Generate a Date Range: List All Dates Between Two Dates

January 13, 2021
Pinal Dave
SQL Tips and Tricks
CTE, SQL DateTime, SQL Scripts, SQL Server

To generate a date range in SQL Server, number the days between a start date and an end date and add each number to the start. This post shows a recursive CTE, its limit of 100 recursions, GENERATE_SERIES, a version for older servers, and how to handle times and missing days.

Read More
Previous 1 2 3 4 5 6 … 29 Next
  • Books
  • Testimonials
  • Privacy Policy

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