Fun with Dates and Times

Steve Jones, 2019-01-16

The other day I got a Github issue that asked if we here at SQLServerCentral should set our dates as YYYYMMDD in the new SQLServerCentral site. The issue noted that there were some inconsistent dates. Article dates are in a similar format, YYYY/MM/DD, but we do have some DD MMM YYYY and a few places where I think the American MMBBYYYY has lived on.

In any case, I made a joke on Twitter of asking if people were alright moving to YYYYMMDD. Most people were in favor, though someone asked about MMMM DD, YYYY, which is easily read. I have to say that I somewhat like that for reading, but as data, as something I'd work with, I prefer having the year month day format. I do want separators, and while I grew up using slashes ( as in YYYY/MM/DD), I know the ISO format is dashes (YYYY-MM-DD). ISO 8601 has dashes, so I decided to add that to the GitHub issue as a way of formatting.

What about using month names? As I look through various sites, I find inconsistencies. Some use dates, like Jan 11, 2019. Others might use 11 Jan 2019 or 2019-01-11. I find that MSDN uses regional settings, so the en-us version of a page will have 01/11/2019, but if I change to the en-Gb version, I see 11/01/2019. That seems find as a UI enhancement, but I hope that the actual value is stored as 2019-01-11. We don't need them time

Or do we? There are times involved. While most of us might not care about whether something was published at 8am or 9am, we might care about where it was published and the time. Certainly 8am in Christchurch if far different from 8am in Honolulu. Do we store time zones? Or keep all dates in one? The logical thing is to keep dates in UTC and then adjust based on the client settings to display something that matches their time zone. We've been storing data in UTC, though the server time has been the Mountain time zone in the US for historical reasons. I don't like that dependency, so I'm sure we'll change that.

Dates and times are both simple and not simple. There are decisions to be made, and far too many of us take them lightly. While the display is of secondary importance, it's likely that we'll often use this data in other systems, as a way of marking a change, or even as a way of ordering our data. Having consistent and known date time formats is important as a data professional. I hope you pay attention to how you gather and store this data.

Rate

5 (1)

Share

Share

Rate

5 (1)

Related content

Mini-Me

Will the next version of Windows be a “Mini-Me” version of Vista? Who knows, and it’s too early to tell, but apparently there’s a mini-kernel version of Windows 7, the one after Vista, which fits into 25MB on disk. That’s a touch lower than the 4GB that Vista takes up. Granted it’s not a full […]

Steve Jones

2007-10-25

59 reads

An Hour in Time

Daylight Savings time switches a little later this year. In fact it’s November 4th this year, after having been in October for all of my life. In case you don’t remember which way we move the clocks, here’s a saying: Spring forward, fall back.

5 (1)

Steve Jones

2007-10-17

199 reads

Software is Like Building a House

One of the really classic analogies in software is that it’s like building a house. You have a foundation, multiple teams, lots of contractors that specialize in something, etc. And it’s an analogy that’s debated as to its relevance over and over. I won’t go into the correctness of this analogy, but I wanted to comment on it.

Steve Jones

2012-10-08 (first published: 2007-10-05)

289 reads