Wednesday, August 21, 2013

Column Compatibility


ISO 8601 is a great format for dates and times because it can be understood as dates and time by the tools you use (databases, spreadsheets, programming languages) - but in anger a lot can be done just by manipulating it as character strings.

  • Want to sort by exact date? Just sort it. It works. You don't even need to know what lexicographic ordering means.
  • Want to roll up by month? Cut off everything after the month, in SQL you can GROUP BY, on the command line you can hit it with the old sort | uniq -c (after you cut or awk or sed it out of whatever you found it in), in Java you are writing that counting code with the HashMaps AGAIN. 
  • Want to look at time of day? Cut the date off the front.
  • Excel will even automatically read it in and recognize it as a date (nice). Of course if you write it back out as a csv no guarantee it stays in ISO 8601 (boo).
Best. Thing. Ever. 

No comments: