How should I best name my timestamp fields?
You should describe the purpose of the column and not necessarily the data type. You can include date/time/timestamp in the name, but you should also include the meaning. For example
- CreationDate
- StartDate
- StatusTime
- Accessed
- Updated
Adding Date/Time/Timestamp and such at the end is particularly useful when the abscence of the addition would conflict with another column. For example, a table may need both a Status and a StatusTime.
How about xyz_at
for a timestamp
and xyz_on
for a date
field - eg start_at
or start_on
?
Normally I'd avoid including the data type in the field name - much better if you can infer what you need to know about the type from the name of any field (a field called description
is unlikely to be an integer
) - but being able to tell the difference between a timestamp
and a date
is often helpful.
I use:
- created_at
- updated_at