views:

30

answers:

2

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.

+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
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
True. Though I store datetimes by habit and filter to the resolution the app needs.
CaseySoftware
This is an old post, but I like to use `dt` as opposed to `date`
vol7ron
+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