Glidder’s associate Anastasia, one of the resident DBAs at Big Blue Box, perpetually ran on Anastasia Time. She always seemed to work late, rushing away for coffee or other, White Rabbit-esque errands.

Eventually, Anastasia moved on, and Glidder got promoted to DBA. His first assignment was a year-old bug filed by Accounting: two reports showed different age groups for the same file.

The first report categorized the files in the correct groups:


CASE WHEN DATEDIFF(day, f.FileDate, @ReportDate) <= 182 THEN '0-6m' 
WHEN DATEDIFF(day, f.FileDate, @ReportDate) > 182 AND DATEDIFF(day, f.FileDate, @ReportDate) <= 365 THEN '6-12m' 
WHEN DATEDIFF(day, f.FileDate, @ReportDate) > 365 AND DATEDIFF(day, f.FileDate, @ReportDate) <= 547 THEN '12-18m' 
WHEN DATEDIFF(day, f.FileDate, @ReportDate) > 547 AND DATEDIFF(day, f.FileDate, @ReportDate) <= 730 THEN '18-24m' 
WHEN DATEDIFF(day, f.FileDate, @ReportDate) > 730 AND DATEDIFF(day, f.FileDate, @ReportDate) <= 1095 THEN '2-3y'
WHEN DATEDIFF(day, f.FileDate, @ReportDate) > 1095 AND DATEDIFF(day, f.FileDate, @ReportDate) <= 1460 THEN '3-4y' 
WHEN DATEDIFF(day, f.FileDate, @ReportDate) > 1460 AND DATEDIFF(day, f.FileDate, @ReportDate) <= 1825 THEN '4-5y' 
WHEN DATEDIFF(day, f.FileDate, @ReportDate) > 1825 THEN '5y+' 

The second report, however, ran on Anastasia Time:

CASE WHEN DATEDIFF(day, f.FileDate, @ReportDate) <= 178 THEN '0-6m' 
WHEN DATEDIFF(day, f.FileDate, @ReportDate) > 178 AND DATEDIFF(day, f.FileDate, @ReportDate) <= 356 THEN '6-12m' 
WHEN DATEDIFF(day, f.FileDate, @ReportDate) > 356 AND DATEDIFF(day, f.FileDate, @ReportDate) <= 534 THEN '12-18m' 
WHEN DATEDIFF(day, f.FileDate, @ReportDate) > 534 AND DATEDIFF(day, f.FileDate, @ReportDate) <= 712 THEN '18-24m' 
WHEN DATEDIFF(day, f.FileDate, @ReportDate) > 712 AND DATEDIFF(day, f.FileDate, @ReportDate) <= 1780 THEN '2-5y'
ELSE '5y+' 

Before he spent too much time figuring out how Anastasia got those numbers, Glidder copied the logic from the accurate report and pasted over the code running on Anastasia Time. No wonder she was always in a hurry, Glidder thought. Her years were only 98% as long as ours.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!