Kamis, 05 Juni 2014

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

 

Hi Andrew

I can see all three of your posts, time-stamped 07:12, 08:19 and 08:30 my local time (UTC+12)

-- Graham

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Friday, 6 June 2014 08:30
To: MS_Access_Professionals@yahoogroups.com
Subject: [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: "Graham Mandeno" <graham@mandeno.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (20)

.

__,_._,___

Tidak ada komentar:

Posting Komentar