Kamis, 05 Juni 2014

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

 

I just realised, again, why I don't post here very often... the yahoo software doesn't like me and keeps silently discarding my posts. Third time lucky...


LIz, I was going to suggest an API/UTC solution similar to Graham's but he got their first and did it better than I had.

However, if I remember correctly, you are using a SQL Server backend and, faced with filling a log table (or just a createdate field) I always use a default value on the field of GETDATE() and don't use any code in th front-end to put any values in the field. That way the field always puts the server's date/time in the field and anyone looking at the data sees all records with the date/time expressed in their local timezone.

In complicated cases, like when old code might be setting incorrect values into the field, I use insert triggers to fix the date/time if they are out by more than a couple of seconds.

You can add a default to an existing table/field:

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

With the TableName and Fieldname texts replaced by the appropriate values.

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 (18)

.

__,_._,___

Tidak ada komentar:

Posting Komentar