Article 6CX7H CodeSOD: Yearly Updates

CodeSOD: Yearly Updates

by
Remy Porter
from The Daily WTF on (#6CX7H)

C. Wiles has the "joy" of working on a SAS application for a large health insurance company. This snippet was extracted some time ago, but the application continues to live on. It has one job: pad the month part of dates to two digits. Let's see how it's done.

%macro yearmonth;if year_month = '2010-1' then year_month = '2010-01';else if year_month = '2010-2' then year_month = '2010-02';else if year_month = '2010-3' then year_month = '2010-03';else if year_month = '2010-4' then year_month = '2010-04';else if year_month = '2010-5' then year_month = '2010-05';else if year_month = '2010-6' then year_month = '2010-06';else if year_month = '2010-7' then year_month = '2010-07';else if year_month = '2010-8' then year_month = '2010-08';else if year_month = '2010-9' then year_month = '2010-09';else if year_month = '2010-10' then year_month = '2010-10';else if year_month = '2010-11' then year_month = '2010-11';else if year_month = '2010-12' then year_month = '2010-12';else if year_month = '2011-1' then year_month = '2011-01';else if year_month = '2011-2' then year_month = '2011-02';else if year_month = '2011-3' then year_month = '2011-03';else if year_month = '2011-4' then year_month = '2011-04';else if year_month = '2011-5' then year_month = '2011-05';else if year_month = '2011-6' then year_month = '2011-06';else if year_month = '2011-7' then year_month = '2011-07';else if year_month = '2011-8' then year_month = '2011-08';else if year_month = '2011-9' then year_month = '2011-09';else if year_month = '2011-10' then year_month = '2011-10';else if year_month = '2011-11' then year_month = '2011-11';else if year_month = '2011-12' then year_month = '2011-12';else if year_month = '2012-1' then year_month = '2012-01';else if year_month = '2012-2' then year_month = '2012-02';else if year_month = '2012-3' then year_month = '2012-03';else if year_month = '2012-4' then year_month = '2012-04';else if year_month = '2012-5' then year_month = '2012-05';else if year_month = '2012-6' then year_month = '2012-06';else if year_month = '2012-7' then year_month = '2012-07';else if year_month = '2012-8' then year_month = '2012-08';else if year_month = '2012-9' then year_month = '2012-09';else if year_month = '2012-10' then year_month = '2012-10';else if year_month = '2012-11' then year_month = '2012-11';else if year_month = '2012-12' then year_month = '2012-12';else if year_month = '2013-1' then year_month = '2013-01';else if year_month = '2013-2' then year_month = '2013-02';else if year_month = '2013-3' then year_month = '2013-03';else if year_month = '2013-4' then year_month = '2013-04';else if year_month = '2013-5' then year_month = '2013-05';else if year_month = '2013-6' then year_month = '2013-06';else if year_month = '2013-7' then year_month = '2013-07';else if year_month = '2013-8' then year_month = '2013-08';else if year_month = '2013-9' then year_month = '2013-09';else if year_month = '2013-10' then year_month = '2013-10';else if year_month = '2013-11' then year_month = '2013-11';else if year_month = '2013-12' then year_month = '2013-12';else if year_month = '2014-1' then year_month = '2014-01';else if year_month = '2014-2' then year_month = '2014-02';else if year_month = '2014-3' then year_month = '2014-03';else if year_month = '2014-4' then year_month = '2014-04';else if year_month = '2014-5' then year_month = '2014-05';else if year_month = '2014-6' then year_month = '2014-06';else if year_month = '2014-7' then year_month = '2014-07';else if year_month = '2014-8' then year_month = '2014-08';else if year_month = '2014-9' then year_month = '2014-09';else if year_month = '2014-10' then year_month = '2014-10';else if year_month = '2014-11' then year_month = '2014-11';else if year_month = '2014-12' then year_month = '2014-12';%mend yearmonth;

The dates, here, come from a database and are concatenated together in the query. Which raises the question: why not do this in the database layer, or perhaps even use the database date formatting features? Or any date formatting? Because if we did that, this wouldn't be a script that needed to be updated every year.

And it is updated, by hand, every year.

buildmaster-icon.png [Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments