views:

425

answers:

11
+2  Q: 

AM/PM Column Name

Without arguing the relative merits of storing a datetime this way...

If you had a column where you stored AM or PM what would you call that column?

EDIT:

I should have figured that there'd be a group of you who couldn't resist being snarky about the idea... Nowhere do you see that I'm about to do this, that I want to do this, that I'm unclear of the myriad of reasons not to do this... but still some of you feel compelled to be priggish and concern yourselves with how much smarter you are rather than take the question for what its worth and offer something useful.

I'm also very pleased that so many aren't deserving of this slur and brought forth some great ideas. Thanks for the thoughts.

Most groups of values have names, the values from 1-24 are known as hours, from 1-12 Months, etc. But for AM/PM what's the name for group, for the collection, for the domain... and they are clearly not "meridiem" because that is the name of a single point in time Noon. That would be like calling AD and BC either Christ's or Lord's. Whereas BCE or CE would probably fit into an "Era" column.

+9  A: 

AM and PM stand for "ante meridiem" and "post meridiem".

So one possibility for the column is: meridiem CHAR(2)

Bill Karwin
A BIT column is definitely preferable.
Jeff
@Jeff: Does a zero signify AM or PM? How would a developer maintaining this app know which is which? Is the overhead of CHAR(2) so much that the data must be encoded in this way?
Bill Karwin
You could compromise with CHAR(1)
Ch00k
Not every DB has BIT.
@Bill: Naming of the bit column will make it obvious if 1 indicates AM or PM.A character field permits thousands of different combinations of alphanumeric characters, whereas we are only interested in the 2 that make sense. Why introduce a possible bug due to dirty data, when you can use bit?
Jeff
@jeff because not every DB has a bit type but every DB does have check constraints. If you're unaware of check constraints to keep your data clean, you really should look them up.
@Mark Brady: Unfortunately, some RDBMS brands don't support check constraints.
Bill Karwin
+2  A: 

I'd call it a terrible idea. Oh, without debating the merits? I'd call it "XM" or "meridiem", but both of these might be confusing. How'bout "amORpm"?

Bill Zeller
'XM' or 'TIME_XM'
John MacIntyre
Someone can punish me later for this, but +1 for terrible idea. Use military time...
Austin Salonen
No, use a DATETIME column.
Joel Coehoorn
Yes, this is a smell that indicates something very wrong. 24h time isn't the solution, though. Storing time as a proper datetime is the solution. That said, poster already knows this so the horror isn't warranted.
Michael Haren
I agree it's a terrible idea, but the OP's question suggests he already knows this.
Bill Karwin
Somehow marketting must have gotten involved in this decision. ;-)
John MacIntyre
I think the OP knows WE'll all think it's a bad idea. Not clear that he believes it himself.
Joel Coehoorn
@John MacIntyre: LOL! That is probably a likely explanation.
Bill Karwin
The question: is What would you call that column... not: should you ever do this. Nowhere in the post did I even intimate that I was about to do this, only that I can't find a word that describes the collection of the two abbreviations.
So you say you know it's a bad idea, and you also say you are not going to do it. So what's the point of the question again?
Graeme Perrow
@Graeme, to figure out the best name for a column that would contain such data.
+8  A: 

Looked up what MS calls it when you specify 't' or 'tt' in a format string, and they just say AM/PM Designator.

That didn't sit well with me, though, because the type of the column (if you must do this) should of course be bit. With that in mind, you want a column name where the value is clearly indicated by the trueness/falseness of the each record's value. Something more like IsPM, IsAM, IsAfterNoon, or IsPostMeridiem.

Joel Coehoorn
I agree, as a bit column that defines a designation it should start with "Is"
Element
Not Every DB has BIT
If the DB doesn't have BIT, then you're likely better off with a different DB. If this isn't possible, then you may be better off with a job with a better company.
Jeff
@Jeff, I think Oracle is a fine database and million of installation and a majority of marketshare tends to prove my opinion has merit. You may be better off ...
Hehe. The lack of a bit column is pretty silly though. "Majority of marketshare" is debatable these days. It really depends on how you define the market. If you are using Oracle, given that you already need at least a CHAR(1) you may just as well go CHAR(2), and that changes things.
Joel Coehoorn
But I think this answer has merit for the general case, because at this point we're already down to your third choice (the first two being use a datetime and bit columns, respectively).
Joel Coehoorn
+4  A: 

Ok so "meridiem" is official technical term for it, but keep in mind another programmer comes along and sees a bit field called this and will likely not know wth it is.

AMPM is a little more descriptive and I think a better name

Neil N
I don't know: I think the context with the rest of date parts would make it pretty clear, and failing that google.
Joel Coehoorn
I work in electricity, is that AmpM? ;-)
+1  A: 

HourPeriod -> first iteration on the clock (am) or second (pm)

Morning -> just store it as a bit

Zombie -> because that's what you are in the AM without your coffee (also, if you're storing datetime this way, you probably don't have strict naming conventions)

Alternatively, you could just do the conversion on the code-side and store the 24-hour time. 13:58 is always 'pm', 1:58 is always 'am'.

Jeff
Cute... and since when do comments require 10 characters. sheesh.
ScottCher
+3  A: 

I'd call it meridiemoffset and store 0 or 12 in it. Easy to convert to AM or PM as necessary, but the main feature is that you can easily calculate the real hour by addition, even inside the SQL statement (which makes sorting easier and more obvious).

Adam Davis
I _almost_ upvoted this, but a bit field gives you the same ability: just multiply the bit value * 12
Joel Coehoorn
That would work too, but wouldn't necessarily save space or increase performance, and for especially heavy usage would decrease performance very slightly. The only drawback I see to this is some idiot later will try to morph this into a timezone.
Adam Davis
If he's worried about performance, he'd use a datetime or 24 hour time.
Joel Coehoorn
Of course, I'd never run words together. But meridiem_offset would be a good name. Best one yet.
+1  A: 

If you can't store time using a 24 hr clock and you HAVE to store AM/PM values, I'd probably have a bit column called PM_Timestamp where 0 = AM and 1 = PM... but I wouldn't like it.

Tina Orooji
I appreciate the way you said that. You answered the OP thoughtfully and you respectfully added that the choice wouldn't make you very happy. That's a very polite way of putting it. hopefully you'll be participating more.
Thank you! I appreciate the comment :o) I do intend to participate more! It's interesting to think about how we'd do things that, as developers, we feel we shouldn't do. Most of the time we can come up with alternate solutions, but it's important to be equally thoughtful when there isn't one.
Tina Orooji
Yes, yes... more helpful, thoughtful, constructive feedback and fewer snarky comments. 8)
ScottCher
A: 

Granted "meridiem" is the most accurate term given the abbreviations. However, it means "noon" in Latin so it could be confusing.

If you're shooting for pure readability (and are adamantly against datetime), I would recommend either IsMorning or IsAfternoon.

Austin Salonen
Why is it "the most accurate term"? You even point out that it means noon which makes it a good flag for, well, noon.
When dealing either ante or post, the column would imply "this meridiem" (AM or PM) but for those who don't know what AM/PM are abbreviations for would look meridiem up, find "noon" and be even more confused (even more if the data is not "AM" and "PM"). This lead to my conclusion of IsMorning ...
Austin Salonen
A: 

If you are using SQLServer, you can wrap non standard text with square brackets and call it "?M" ... so you'd use it like mytable.[?M] ;-)

PS-I know this can be done because my predecessor did it.

John MacIntyre
That's very interesting.
+1  A: 

I think AMPM is the best choice. It's immediately obvious what it's meant to be.

Mike K.
+1  A: 

How about:

 AM_OR_PM
David Aldridge