views:

32

answers:

5

If I create a table with datetime default getdate() field that is intended to keep date&time of record insertion, which name is better to use for that field ?

I like to use Created and I've seen people use DateCreated or CreateDate.

Other possible candidates that I can think of are: CreatedDate, CreateTime, TimeCreated, CreateDateTime, DateTimeCreated, RecordCreated, Inserted, InsertedDate, ...

From my point of view anything with Date inside name looks bad because it can be confused with date part in case if I have 2 fields: CreateDate,CreateTime, so I wonder if there are any specific recommendations/standards in that area based on real reasons, not just style, mood or consistency.

Of course, if there are 100 existing tables and this is table 101 then I would use same naming convention as used in those 100 tables for the sake of consistency, but this question is about first table in first database in first server in first application.

+1  A: 

For the name of the column in the database, I like created_at.

And for the name of the property in the object used in my code, I like createdAt.


Not sure there is any "official" way of naming that kind of field -- but that's the default name of a well-used ORM in PHP, and I've kept that convention even for projects in which I don't use that convention.

Pascal MARTIN
A: 

I always use CreatedDate in these circumstances, and it gives a template for other dates - UpdatedDate, DeletedDate, PurchasedDate and so on.

amelvin
alpav
Date and time - it seems to be a waste to not record the time when its already there.
amelvin
+3  A: 

Why not just use plain on Created, or CreatedOn. Windows OS uses three date properties for files.

Created:
Modified:
Accessed:

So you could try to keep that sort of convention if you prefer.

galford13x
A: 

I always use these these column names:

CreateDate  --when they did it
CreateID    --who who did it

LastChgDate --when they did it
LastChgID   --who who did it
KM
+2  A: 

I tend to InsertedDateTime and InsertedBy (and Updated%, Affected% for indirect updates perhaps, Deleted% for logical deletes).

OperationDateTime for general auidt table

If I was storing a date only, it would be StartDate. Likewise, time only would be BookedTime

Another rule is to avoid "SQL" teams, so Added/Changed rather then Inserted/Updated. I inherited Inserted/Updated and it's consistent at least

Just be consistent: no mixing Created% with Inserted% with Added%

gbn