What's a good way of naming date/datetime fields? Can't decide if I want to use things like expiry_date
, end_time
, created_on
, or simply expires
, modified
.
views:
30answers:
2
+2
A:
I generally use "date_" as a prefix:
date_created
date_end
date_deleted
date_modified
As long as you're consistent, you should be in good shape. Alternatively, if you're working on an existing product, follow their standard. Changing conventions part of the way through is just annoying for the people behind you.
CaseySoftware
2010-06-17 01:58:57
Most date fields I'm aware of are (rightly) much higher resolution than day. Usually they are down to the second, and often have higher resolution than that. As such, 'time_' might be a more accurate prefix, but the term date has a lot of history behind it and conveys meaning well.
Slartibartfast
2010-06-17 02:29:08
True. Though I store datetimes by habit and filter to the resolution the app needs.
CaseySoftware
2010-06-17 03:18:25
This is an old post, but I like to use `dt` as opposed to `date`
vol7ron
2010-10-04 14:32:44
+1
A:
I think either standard is okay but personally I find a column name like "modified" ambiguous without seeing the associated data type — is it boolean, a date, or a user ID? I would prefer "modified_on", "modify_date", "is_modified", "modified_by" or something like that.
Larry Lustig
2010-06-17 02:02:01