Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Adjusting Timestamps

2 posts in General Discussion Last posting was on 2003-01-15 19:25:28.0Z
Karl_Ross Posted on 2003-01-14 23:10:25.0Z
From: Karl_Ross
Date: Tue, 14 Jan 2003 18:10:25 -0500
Newsgroups: ianywhere.public.general
Subject: Adjusting Timestamps
Message-ID: <10FB23DBE1156980007F4BDA85256CAE.007F4BE985256CAE@webforums>
Lines: 17
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com!webforums.sybase.com!news
Xref: forums-1-dub ianywhere.public.general:314
Article PK: 2137

Hi,

Is it possible to use an offset when inserting a timestamp field?
For example, let's say you had a webserver located in NY and someone from
California logged in. In your application you want to capture when they
last signed in. The problem is, if you simply use a timestamp field in
conjunction with an SQL insert statement that has DEFAULT as the parameter,
you will always get the time on the server in NY. What I am looking to do
is to set a field in the user table to indicate an offset (in hours) so
that all inserts could be adjusted correctly. Ideally the insert might
look like :
INSERT INTO sign_on_log VALUES (DEFAULT - 3,'ID2218'). What is the best
way to accomplish this? Is this a case for a stored procedure or Java Code
in the database or would it make sense to write some code to hand calculate
the timestamp value out to the millisecond and then just insert with a
variable instead of DEFAULT. Thanks for any insights.

Karl Ross


Graham Hurst Posted on 2003-01-15 19:25:28.0Z
Message-ID: <3E25B5A8.DB7575BF@ianywhere.com>
Date: Wed, 15 Jan 2003 14:25:28 -0500
From: Graham Hurst <spam_guard_hurst@ianywhere.com>
Organization: iAnywhere Solutions (a Sybase company)
X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Subject: Re: Adjusting Timestamps
References: <10FB23DBE1156980007F4BDA85256CAE.007F4BE985256CAE@webforums>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: ianywhere.public.general
Lines: 48
NNTP-Posting-Host: 172.31.143.29
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub ianywhere.public.general:311
Article PK: 2128

Usually it's best to use UTC time in the server and have the application convert
to its locale's timezone. FYI, we added some timezone specific features in the
8.0.0 release that might help. The following is from the What's New section for
release 8.0.0:

Timezone adjustment
To permit easier coordination of date/time values across time zones, the
following new features have been added:

CURRENT UTC TIMESTAMP
Adjusts the time zone value by the server's time zone adjustment value.

DEFAULT UTC TIMESTAMP
Specifies a default value for INSERTs and sets updated columns to the value.

TimeZoneAdjustment property
returns the number of minutes that must be added to the Coordinated Universal
Time (UTC) to display the new local time.

TIME_ZONE_ADJUSTMENT option
Allows a connection's time zone adjustment to be modified.

Karl_Ross wrote:
>
> Hi,
>
> Is it possible to use an offset when inserting a timestamp field?
> For example, let's say you had a webserver located in NY and someone from
> California logged in. In your application you want to capture when they
> last signed in. The problem is, if you simply use a timestamp field in
> conjunction with an SQL insert statement that has DEFAULT as the parameter,
> you will always get the time on the server in NY. What I am looking to do
> is to set a field in the user table to indicate an offset (in hours) so
> that all inserts could be adjusted correctly. Ideally the insert might
> look like :
> INSERT INTO sign_on_log VALUES (DEFAULT - 3,'ID2218'). What is the best
> way to accomplish this? Is this a case for a stored procedure or Java Code
> in the database or would it make sense to write some code to hand calculate
> the timestamp value out to the millisecond and then just insert with a
> variable instead of DEFAULT. Thanks for any insights.
>
> Karl Ross