One of my pet pevs is the choices people make with regard to date formatting. Doesn’t matter if it’s written on paper, on a cafe chalkboard, displayed in an app or blog post, the effect on me is the same – frustratingly annoying.
What am I talking about specifically? Short-hand dates based on the authors locale but ignorant of the fact it will most likely be viewed by others around the globe or from a foreign land.
When I see a date like 3/7/15 I do not know if it’s 7th of March 2015 or 3rd of July 2015. The time it takes me to infer the date (by looking for a reference point, like the mention of a city, state or country etc) takes too long and distracts from the article I’m reading or from my general thought flow – it shouldn’t have to be this way.
What’s wrong with presenting short dates like so: 3-Jul-15 ?? There’s no confusion. No ambiguity. No wasted brain power expended on inferring the actual date the author intended. Faster to visually scan. It’s dead simple. Straight forward. Polite/thoughtful/good etiquette. Just plain common sense in my book.
Here’s a quick table that illustrates my point further. I’d be very happy with any of the formatting options shown:
|Ambiguous Date||Presentation Option||T-SQL|
|3/7/15||03JUL15||SELECT upper(replace(convert(varchar, getdate(), 6),’ ‘,”))|
|3/7/15||3-Jul-15||SELECT replace(convert(varchar, getdate(), 6),’ ‘,’-‘)|
|3/7/15||03 Jul 15||SELECT convert(varchar,getdate(),6)|
|3/7/15||03 Jul 2015||SELECT convert(varchar,getdate(),106)|
|3/7/15||3rd July 2015||(needs a custom ordinal function)|
|3/7/15||Jul 03, 15||SELECT convert(varchar, getdate(), 7)|
|3/7/15||Jul 03, 2015||SELECT convert(varchar, getdate(), 107)|
So people, please, please, PLEASE … chose your date format carefully. For my sanity and many others around the globe.
Take-away: Try and use words instead of numbers for the month portion of your date. Then the entire date will be instantly recognisable.
Date Vetting Council
(sorry, threw that signature in for fun!)
* Table listing all SQL Server DateTime to VarChar formats
* A SQL date formatting function I’ve written to help you all out
* Microsoft Date and Time Data Types and Functions
* Useful SQL Date Functions from W3School
* A guide to the datetime datatypes from SQL 7.0 onwards from karaszi.com
* Wikipedia style guide for dates and numbers