Kamis, 05 Juni 2014

[MS_AccessPros] Re: now() with time zone adjustment

 

I'm not sure, either I hate this Yahoo forum software because it keeps not posting my replies or if it hates me and thus does not post my replies...


Liz, I was going to suggest the API and UTC route but Graham got there first and did it better than I had.

However, if I remember correctly you are using SQL Server for the backend and in this case I would always put a defaul value on the log date/time field so that it always recorded the server time and not whatever time was on the system it was being updated from.

You can add the default if it's not there:

ALTER TABLE [TableName] ADD CONSTRAINT [DF_TableName_Fieldname] DEFAULT GETDATE() FOR FieldName

Substituting TableName and Fieldname for their appropriate values.

Then you should not set the value of the field, or allow the field to be set, in your add/insert. The SQL Server will fill the field with the date/time it happened. Furthermore, anyone viewing the data should see all thedates/times expressed in their local context.

In complicated cases, cases where I can't guarantee that legacy code will not set the date/time, I use an insert trigger on the table to set the date/time value to the local getdate() if it differs more than a couple of seconds.

Yours,
Andrew

__._,_.___

Posted by: yahoo@craven.de
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (16)

.

__,_._,___

Tidak ada komentar:

Posting Komentar