472,982 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,982 software developers and data experts.

Strange DateTime Problem

All,

I'm using a WinForm app that calls methods on a remotable object. The
app server hosting the object is in New York. Using the same exact
application, a Sql Server 2005 datetime column's info is being
displayed as '3/25/2008' in California and '3/26/2008' in New York
(outside the LAN) where the data in the column is '3/26/2008 12:00:00
AM' (I'm converting the to the short date format in the app code). I
can get the California app to display the correct short date if I edit
the date in Sql Server to a time later in the day (i.e. '3/26/2008
10:00:00 AM'). What's the deal? Time zones?? Can't be...

Thanks
Mar 26 '08 #1
7 1777

"Looch" <lu**********@yahoo.comwrote in message
news:e3**********************************@59g2000h sb.googlegroups.com...
All,

I'm using a WinForm app that calls methods on a remotable object. The
app server hosting the object is in New York. Using the same exact
application, a Sql Server 2005 datetime column's info is being
displayed as '3/25/2008' in California and '3/26/2008' in New York
(outside the LAN) where the data in the column is '3/26/2008 12:00:00
AM' (I'm converting the to the short date format in the app code). I
can get the California app to display the correct short date if I edit
the date in Sql Server to a time later in the day (i.e. '3/26/2008
10:00:00 AM'). What's the deal? Time zones?? Can't be...
Try DateTimeOffset?
Mar 26 '08 #2
Thanks for the quick responses.

I'm certainly not disagreeing but I don't get it. The remotable object
method in question selects four fields from the db (one being the
datetime type mentioned above), uses those four items to set
MyObject's four properties, adds MyObject to an array list, serializes
that array list to binary and sends over http. The client
deserializes, looks in the array list, casts the object to MyObject
type and displays the properties in separate text boxes.

Where/why would the CLR manipulate the date property based on the
local time zone before displaying the value?

(Interstingly I found the threshold to be '3/26/2008 4:00:00 AM' to be
where the west coast app will actual display '3/26/2008' - '3/26/2008
3:59:59 AM' will still show '3/25/2008'. Could the '3' in the hours
place be related to the three hour difference between the east and
west coast?).

Thanks again for the help.
Mar 26 '08 #3
I found the answer - DateTime.AddHours

Thanks again.

Mar 26 '08 #4
Looch wrote:
Thanks for the quick responses.

Where/why would the CLR manipulate the date property based on the
local time zone before displaying the value?
serializes
that array list to binary and sends over http.
the serialized date will include a time zone...
>The client
deserializes,
deserializing will adjust the date to local time.
Mar 27 '08 #5
On Mar 26, 11:31 pm, Looch <lucianoj2...@yahoo.comwrote:
Thanks for the quick responses.

I'm certainly not disagreeing but I don't get it. The remotable object
method in question selects four fields from the db (one being the
datetime type mentioned above)
<snip>

If you consider that this date/time can be create/edit date/time...
User 1 in New York creates/edits the record, User 2 in California
opens the same record few minutes later...
What do you expect User 2 to see? That the particular record WILL be
created/edited in 3 Hours and 55 minutes?
Mar 27 '08 #6
I guess I was expecting that if User1 (in New York) created a record
where one of the columns is a datetime type and the value created was
'3/26/2008 3:12:53 AM' that if User2 in California queried that record
and returned the value of that same column the return value would be
'3/26/2008 3:12:53 AM'. Instead I was getting the value minus four
hours.
Mar 27 '08 #7
The issue is, I think you find when you delve deeper, is one of
serialization.

The remoting host (at the server end), will be serializing the datetime, and
the local remoting client will be deserializing it.

Unless it is told otherwise, the remoting host will including timezone
information in the serialized datetime. The timezone information will be is
respect of the timezone setting for the 'box' on which the serialization is
performed.

When the local remoting client deserializes it, because it contains timezone
information, that timezone information is honoured. The interpretation of
the value will be in respect of the timezone setting for the 'box' on which
the deserialization is performed, but taking into account the timezone
information embedded in the serialized value.

For example the value of:
3/26/2008 3:12:53 AM
will be serialized as something like:
2008-03-26T03:12:53Z+4:00

To get the behaviour you want, you would need to code the host and client
portions of the remotable application to ensure that all datetime values are
serialized and deserialized in a timezone agnostic manner.

Clear as mud????
"Looch" <lu**********@yahoo.comwrote in message
news:03**********************************@i7g2000p rf.googlegroups.com...
>I guess I was expecting that if User1 (in New York) created a record
where one of the columns is a datetime type and the value created was
'3/26/2008 3:12:53 AM' that if User2 in California queried that record
and returned the value of that same column the return value would be
'3/26/2008 3:12:53 AM'. Instead I was getting the value minus four
hours.
Mar 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: john | last post by:
Hi,All Gurus: It is kind of complicated, please bear with me and let me know if you have any questions. Thanks a lot in advance. John I have a csharp method, using emit to dynamically generate...
0
by: Davewadd | last post by:
I'm having an odd problem with a datagrid in a c# program. The program maintains a schedule of jobs that need to be run. As jobs run, the status and next run date/time info are updated in a SQL...
3
by: Jim in Arizona | last post by:
I'm going insane! I don't know if it's just that the .net 2.0 framework is buggy or if it really is my code. This is pretty hard to explain since I can't even begin to nail down why this is...
0
by: David Pratt | last post by:
Hi. I am creating a couple of small methods to help me manage time from UTC as standard but I am getting strange results. If I start with a datetime of 2005-12-12 14:30:00 in timezone...
14
by: dananrg | last post by:
Been using the ODBC module for Python 2.1 (Win32) and had another question. When I return data from date columns, it's in a strange object form, e.g. <something or other> (don't have the output in...
1
by: Tino Lange | last post by:
Hi! I'm surprised about the following code, maybe you can give me a hint whether that's bug or feature? I'm just trying to convert local time to GMT and one method gives a strange result: ...
3
by: Jeremy Chapman | last post by:
I've created a web service method which looks like public MatchResult CheckMatch(MatchData MatchValues) MatchData is a class defined as: public class MatchData { public string GivenName;...
4
by: Smith | last post by:
Hello experts, I have the following peice of code in my Global.asax void Application_Error(object sender, EventArgs e) { //get reference to the source of the exception chain
2
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.