i have a website that uses nhibernate to speak to SQL Server 2005.
I now want every record to have a createdDateTime and lastUpdatedDateTime field. Where should this value be set. i am worries about things like timezones, consistency, etc . . any thoughts on the options below:
- Inside my application code (right before i do a write)
- Inside SQL Server (using triggers or other functions)
- Other ??
Those are best handled directly by SQL Server to ensure true data integrity. As far as consistency is concerned, the server time will be used so there shouldn’t be problems. You could use UTC time in SQL Server as @gbn suggests in the comments.