JH supports web-based property management software, which is exactly as exciting as it sounds. We've all been there: obsolete tech—their database was running SQL Server 2000 long past its sunset date—and outsourced development. The Indian office had a problem to solve: they'd already written a database function to return all completed work orders for a given tenant's unit, but since notifications were only sent once a day, the client wanted to scoop up any work orders from the previous day that were completed after that day's notification was sent. JH could have modified the function to look back at the previous day in five minutes, but then his company would have missed out on the incredible cost and efficiency gains of offshoring. Instead, JH was tasked with reviewing the code. The first thing he noticed was that, instead of just comparing the work order dates to the current date using SQL Server's GETDATE() function, the technician did this:

where datediff(day, @asofDate, wo.DTWCOMPL) between -1 and 0

Puzzled by the mystery variable, JH did a search for @asofDate, and found:

SELECT @asofDate = Now From vw_GetDate;

JH didn't recognize vw_GetDate, either, nor did he know why you'd look up the current date in a view. Opening the script the technician had written to define the original function revealed this gem:


He marked the code review failed and re-opened the change request. Offshoring! The modern miracle!

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