My sample trigger SQL code in TSSQL for a SQL Server database for a Date.
CREATE TRIGGER img_file1_lastchanged ON [dbo].[IMG_FILE1]
FOR INSERT, UPDATE
AS
UPDATE img_file1 SET lastchanged = getdate()
More or less based on this:
http://www.sqlteam.com/article/creating-a-date-updated-field-in-tables
Another trigger example with CAST:
/* Create the 10 digit style member_number */
CREATE TRIGGER create_member_number ON [dbo].[member]
FOR INSERT AS
UPDATE member SET member_number = '123' + RIGHT('0000000' + CAST(member_id AS varchar), 7)
Tags: trigger, sqlserver, msssql, update, lastchanged, timestamp, automatic, sql