473,407 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Dates and time zones

Hello!

I've built a program that show some dates to users. I got a problem when
users have different configured time zone machines, where:

- One machine that determined time zone the date displayed is 01/01/2006.
- In other different machine (and other configured time zone), the date
displayed is 12/31/2006 19:00:00

If I redefine the time zones of these two machines to the same, the date
works fine.

I think this: if the date is registered as 01/01/2006, it should be showed
as 01/01/2006, independent of fix it in CultureInfo class. Or I'm wrong?

Why does this happen and how to resolve it?

[]s
Cesar
Dec 12 '05 #1
14 2612
"Cesar Ronchese" <ronchese_hotmail_dot_com> schrieb
Hello!

I've built a program that show some dates to users. I got a problem
when users have different configured time zone machines, where:

- One machine that determined time zone the date displayed is
01/01/2006. - In other different machine (and other configured time
zone), the date displayed is 12/31/2006 19:00:00

If I redefine the time zones of these two machines to the same, the
date works fine.

I think this: if the date is registered as 01/01/2006, it should be
showed as 01/01/2006, independent of fix it in CultureInfo class. Or I'm
wrong?

Why does this happen and how to resolve it?

Which version of VB do you use? 2003 or 2005? I ask because DateTime now has
a property 'Kind'. Apart from this: Where do you get the DateTime from?
Where do you store it (type of variable)? How do you display it? What is the
value in the variable?
Armin

Dec 12 '05 #2
I'm using VB.Net 2003.

The date is typed in a textbox and stored in a column (date datatype) in a
datatable, and further stored in a SQL Server database (also date datatype).
I checked via Query Analyzer and the date is correctly stored. So, when I
show that date in another machine, the problem occurs.

The date typed is 01/01/2006, although it happens with every date I save.


"Armin Zingler" <az*******@freenet.de> wrote in message
news:um*************@TK2MSFTNGP12.phx.gbl...
"Cesar Ronchese" <ronchese_hotmail_dot_com> schrieb
Hello!

I've built a program that show some dates to users. I got a problem
when users have different configured time zone machines, where:

- One machine that determined time zone the date displayed is
01/01/2006. - In other different machine (and other configured time
zone), the date displayed is 12/31/2006 19:00:00

If I redefine the time zones of these two machines to the same, the
date works fine.

I think this: if the date is registered as 01/01/2006, it should be
showed as 01/01/2006, independent of fix it in CultureInfo class. Or I'm
wrong?

Why does this happen and how to resolve it?

Which version of VB do you use? 2003 or 2005? I ask because DateTime now
has
a property 'Kind'. Apart from this: Where do you get the DateTime from?
Where do you store it (type of variable)? How do you display it? What is
the value in the variable?
Armin

Dec 12 '05 #3
"Cesar Ronchese" <ronchese_hotmail_dot_com> schrieb
I'm using VB.Net 2003.

The date is typed in a textbox and stored in a column (date
datatype) in a datatable, and further stored in a SQL Server
database (also date datatype). I checked via Query Analyzer and the
date is correctly stored. So, when I show that date in another
machine, the problem occurs.

The date typed is 01/01/2006, although it happens with every date I
save.

I'm afraid, I don't know whether the SQL server can store timezone
information along with the date. ... According to the docs, it doesn't.

How do you display the date on the other machine? I must admit, currently, I
don't know (yet) where timezone information is taken into account on the way
from your textbox to the other machine.
Armin

Dec 12 '05 #4
Yea, the SQL Server is storing the date correctly, with no timezone
information.
I did some more tests, and I find that the changed date come already from
the datatable object.

You think, perhaps, I should force something in the CultureInfo class,
anyway?

"Armin Zingler" <az*******@freenet.de> wrote in message
news:u4**************@TK2MSFTNGP12.phx.gbl...
"Cesar Ronchese" <ronchese_hotmail_dot_com> schrieb
I'm using VB.Net 2003.

The date is typed in a textbox and stored in a column (date
datatype) in a datatable, and further stored in a SQL Server
database (also date datatype). I checked via Query Analyzer and the
date is correctly stored. So, when I show that date in another
machine, the problem occurs.

The date typed is 01/01/2006, although it happens with every date I
save.

I'm afraid, I don't know whether the SQL server can store timezone
information along with the date. ... According to the docs, it doesn't.

How do you display the date on the other machine? I must admit, currently,
I
don't know (yet) where timezone information is taken into account on the
way
from your textbox to the other machine.
Armin

Dec 12 '05 #5
"Cesar Ronchese" <ronchese_hotmail_dot_com> schrieb
Yea, the SQL Server is storing the date correctly, with no timezone
information.
I did some more tests, and I find that the changed date come already
from the datatable object.

The datatable on the machine where the date is entered in the textbox? How
do you put the text in the textbox into the datatable?
BTW, your machine's timezone information is wrong. Please correct it. That's
the first thing I would do. :-) (I answer one hour before you ask).
Armin

Dec 12 '05 #6
I noticed this is like you creating a file in a such machine and opening the
Windows Explorer in other machine configured with different time zone. The
date displayed is according difference of your location.

For sample:
- create the file at 10:00am in some machine
- choose other machine and set the time zone to +3:00h, for sample
- open Windows Explorer in that second machine and access that first
machine, and see your created file
- see the creation date of that file. Is -3:00h

But I would like not apply this to my application :((

The users can accidentally keep some incorrect configuration on the machine
and the dates can be misviewed, which can occurs in financial loses if
misinterpreted.



"Cesar Ronchese" <ronchese_hotmail_dot_com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Yea, the SQL Server is storing the date correctly, with no timezone
information.
I did some more tests, and I find that the changed date come already from
the datatable object.

You think, perhaps, I should force something in the CultureInfo class,
anyway?

"Armin Zingler" <az*******@freenet.de> wrote in message
news:u4**************@TK2MSFTNGP12.phx.gbl...
"Cesar Ronchese" <ronchese_hotmail_dot_com> schrieb
I'm using VB.Net 2003.

The date is typed in a textbox and stored in a column (date
datatype) in a datatable, and further stored in a SQL Server
database (also date datatype). I checked via Query Analyzer and the
date is correctly stored. So, when I show that date in another
machine, the problem occurs.

The date typed is 01/01/2006, although it happens with every date I
save.

I'm afraid, I don't know whether the SQL server can store timezone
information along with the date. ... According to the docs, it doesn't.

How do you display the date on the other machine? I must admit,
currently, I
don't know (yet) where timezone information is taken into account on the
way
from your textbox to the other machine.
Armin


Dec 12 '05 #7
Yes, the datatable is in the machine I entered the date. Then, I close the
applications in that machine and open it again. The date come wrong. :-O

I put the date from Textbox to DataTable using a format yyyy/mm/dd. But it
seems OK, because it is correctly stored in SQL Server.

I wrote a message before you respond, because I did not know if you are
online atm, then I paste below, with correction.
:))

= = =
I noticed this is like you creating a file in a such machine and opening the
Windows Explorer in other machine configured with different time zone. The
date displayed is according difference of your location.

For sample:
- create the file at 10:00am in some machine
- choose other machine and set the time zone to +3:00h, for sample
- open Windows Explorer in that second machine and access that first
machine, and see your created file
- see the creation date of that file is +3:00h

But I would like not apply this to my application :((

The users can accidentally keep some incorrect configuration on the machine
and the dates can be misviewed, which can occurs in financial loses if
misinterpreted.



"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
"Cesar Ronchese" <ronchese_hotmail_dot_com> schrieb
Yea, the SQL Server is storing the date correctly, with no timezone
information.
I did some more tests, and I find that the changed date come already
from the datatable object.

The datatable on the machine where the date is entered in the textbox? How
do you put the text in the textbox into the datatable?
BTW, your machine's timezone information is wrong. Please correct it.
That's the first thing I would do. :-) (I answer one hour before you
ask).
Armin

Dec 12 '05 #8
"Cesar Ronchese" <ronchese_hotmail_dot_com> schrieb
I noticed this is like you creating a file in a such machine and
opening the Windows Explorer in other machine configured with
different time zone. The date displayed is according difference of
your location.

For sample:
- create the file at 10:00am in some machine
- choose other machine and set the time zone to +3:00h, for sample -
open Windows Explorer in that second machine and access that first
machine, and see your created file
- see the creation date of that file. Is -3:00h

But I would like not apply this to my application :((

The users can accidentally keep some incorrect configuration on the
machine and the dates can be misviewed, which can occurs in
financial loses if misinterpreted.

Well,

1) Please answer my other question first.

2) I understand you, but in your case, this actually should not happen. We
are already about to find out why different values are displayed.

3) You really must handle this problem because it is often disregarded: If
you display a date/time value, you have to think about in which time zone
you want to display it. You also must think about the time zone if you store
it in a database. Both is important! If you store a value in a database you
should store the UTC value. Example:

If you enter 1/1/2006 05:00 AM on machine #1 in a textbox, which time zone
is it? Usually it is the local time. Let's assume it is +2 hours. Now you
store this value in a database. Machine #2's time zone is +5 hours. On
machine #2, the value is loaded from the database. Now, which value do you
intend to display?

a) machine #1's time zone: "1/1/2006 05:00 AM"
b) UTC: "1/1/2006 03:00 AM"
c) machine #2's time zone: "1/1/2006 08:00 AM"

Version a) is not possible because machine #2 does not know the time zone of
machine #1. Therefore, only b) and c) can be used. Version a) would only be
possible if machine #1's time zone was stored along with the value in the
database. This wouldn't make (a lot) sense because version b) was better.
Now, you must choose between b) and c). That's up to you. As you see in
Windows Explorer, it uses c). What you choose depends on your needs. In any
case, it must be clear which time zone is it. So, if you go with b), you
should display
"1/1/2006 03:00 AM UTC".
Anyway, with the situation you describe, there shouldn't be a difference at
all. So, please see 1).

Armin

Dec 12 '05 #9
"Cesar Ronchese" <ronchese_hotmail_dot_com> schrieb
Yes, the datatable is in the machine I entered the date. Then, I
close the applications in that machine and open it again. The date
come wrong. :-O

I put the date from Textbox to DataTable using a format yyyy/mm/dd.
But it seems OK, because it is correctly stored in SQL Server.
Please be a little bit more detailled because I still don't know how the
value is converted and moved to the datatable.

Do you use databound controls? Where do you use this format? yyyy/mm/dd is
not dd/mm/yyyy that you use for entering. Do you manually convert it using
Datetime.Parse? Can you show some code?

How do know which value is stored in the datatable? Do you see it while
debugging? How do you show it during debugging? How do you check which value
is stored in SQL server (I'm not an SQL server expert but maybe you only
show the date part?)?

I wrote a message before you respond, because I did not know if you
are online atm, then I paste below, with correction.
:))

Now I wrote a mesage before you responded. :-)
Armin

Dec 12 '05 #10
Armin,

This is weird, I always expected it was on UTC starting time, however I can
that as well not find written.

Cor
Dec 12 '05 #11
Cesar,

Beside the timezone as Armin told what I am no as well not any more sure
about..

If you use one SQL server, than the DateTime will always be the same. (in
SQL server and in Access). It is are ticks in 1000/3 milliseconds starting
at 1-1-1753 00:00:00 (usa notation 1-1-1753 12:00:00)

To bring a string to a date, you should try to avoid hard paterns (custom
paterns), but use the paterns.

http://msdn.microsoft.com/library/de...classtopic.asp

To bring a string to a date you have 3 methods in VB
CDate, Convert.ToDateTime(...), DateTime.Parse(..............)

In normal situations CDate should be what the ser expect aacoording to his
system settings.

C# shows in Visual Studio Net the dates accoording to the system setting of
a system. VB Net shows them at the moment only in USA format. Month:Day:Year

To interact between datetime in Net (which uses ticks representing 100
nanoseconds starting at 1-1-1) you should use parameters.

http://www.vb-tips.com/default.aspx?...6-7139b8970071

I hope this helps a little bit.

Cor
"Cesar Ronchese" <ronchese_hotmail_dot_com> schreef in bericht
news:Ov*************@TK2MSFTNGP12.phx.gbl...
Yes, the datatable is in the machine I entered the date. Then, I close the
applications in that machine and open it again. The date come wrong. :-O

I put the date from Textbox to DataTable using a format yyyy/mm/dd. But it
seems OK, because it is correctly stored in SQL Server.

I wrote a message before you respond, because I did not know if you are
online atm, then I paste below, with correction.
:))

= = =
I noticed this is like you creating a file in a such machine and opening
the
Windows Explorer in other machine configured with different time zone. The
date displayed is according difference of your location.

For sample:
- create the file at 10:00am in some machine
- choose other machine and set the time zone to +3:00h, for sample
- open Windows Explorer in that second machine and access that first
machine, and see your created file
- see the creation date of that file is +3:00h

But I would like not apply this to my application :((

The users can accidentally keep some incorrect configuration on the
machine
and the dates can be misviewed, which can occurs in financial loses if
misinterpreted.



"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
"Cesar Ronchese" <ronchese_hotmail_dot_com> schrieb
Yea, the SQL Server is storing the date correctly, with no timezone
information.
I did some more tests, and I find that the changed date come already
from the datatable object.

The datatable on the machine where the date is entered in the textbox?
How do you put the text in the textbox into the datatable?
BTW, your machine's timezone information is wrong. Please correct it.
That's the first thing I would do. :-) (I answer one hour before you
ask).
Armin


Dec 12 '05 #12
"Cor Ligthert [MVP]" <no************@planet.nl> schrieb
Armin,

This is weird, I always expected it was on UTC starting time,
however I can that as well not find written.

What are you referring to? SQL server? Well, it's neither UTC nor local,
it's simply a date/time without further time zone information. (see my next
post)
Armin

Dec 12 '05 #13
Ok, Armin, I read the other message, I agreed with your thinks.

I'll write some piece of codes so you can understand what my application do.

And, sorry for not say this before, but writing the sample code, I remember
the following detail now: the data is transfered via Remoting, and this
characteristic is doing the changes on dates! If I write a direct database
access, it works well.

I'm writing the code now.


"Armin Zingler" <az*******@freenet.de> wrote in message
news:OY**************@tk2msftngp13.phx.gbl...
"Cesar Ronchese" <ronchese_hotmail_dot_com> schrieb
Yes, the datatable is in the machine I entered the date. Then, I
close the applications in that machine and open it again. The date
come wrong. :-O

I put the date from Textbox to DataTable using a format yyyy/mm/dd.
But it seems OK, because it is correctly stored in SQL Server.


Please be a little bit more detailled because I still don't know how the
value is converted and moved to the datatable.

Do you use databound controls? Where do you use this format? yyyy/mm/dd is
not dd/mm/yyyy that you use for entering. Do you manually convert it using
Datetime.Parse? Can you show some code?

How do know which value is stored in the datatable? Do you see it while
debugging? How do you show it during debugging? How do you check which
value is stored in SQL server (I'm not an SQL server expert but maybe you
only show the date part?)?

I wrote a message before you respond, because I did not know if you
are online atm, then I paste below, with correction.
:))

Now I wrote a mesage before you responded. :-)
Armin

Dec 12 '05 #14
Armin, Cor,

I'm taking some time to get the sample done, and I need to get out for a
while. At tomorrow I'll post the code sample here, inside new message.

For this time, thanks for the effort!

[]s
Cesar

"Cesar Ronchese" <ronchese_hotmail_dot_com> wrote in message
news:uJ**************@TK2MSFTNGP09.phx.gbl...
Ok, Armin, I read the other message, I agreed with your thinks.

I'll write some piece of codes so you can understand what my application
do.

And, sorry for not say this before, but writing the sample code, I
remember the following detail now: the data is transfered via Remoting,
and this characteristic is doing the changes on dates! If I write a direct
database access, it works well.

I'm writing the code now.


"Armin Zingler" <az*******@freenet.de> wrote in message
news:OY**************@tk2msftngp13.phx.gbl...
"Cesar Ronchese" <ronchese_hotmail_dot_com> schrieb
Yes, the datatable is in the machine I entered the date. Then, I
close the applications in that machine and open it again. The date
come wrong. :-O

I put the date from Textbox to DataTable using a format yyyy/mm/dd.
But it seems OK, because it is correctly stored in SQL Server.


Please be a little bit more detailled because I still don't know how the
value is converted and moved to the datatable.

Do you use databound controls? Where do you use this format? yyyy/mm/dd
is not dd/mm/yyyy that you use for entering. Do you manually convert it
using Datetime.Parse? Can you show some code?

How do know which value is stored in the datatable? Do you see it while
debugging? How do you show it during debugging? How do you check which
value is stored in SQL server (I'm not an SQL server expert but maybe you
only show the date part?)?

I wrote a message before you respond, because I did not know if you
are online atm, then I paste below, with correction.
:))

Now I wrote a mesage before you responded. :-)
Armin


Dec 12 '05 #15

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

Similar topics

12
by: David Lindsay | last post by:
I want to put date and time on my web page, and to be sure it tracks the BST/ GMT changes. Can anyone help me, I have gone back in my historic file for quite a while and not found anything. Sorry...
1
by: heirou | last post by:
I'm a novice in this subject....I've made a database that requires a time conversion. For example, if local time is 1200, determine the time in Korea. I use two fields: a date field, and a time...
6
by: Mark Rae | last post by:
Hi, I'm busy implementing a PayPal solution at the moment, part of which involves adding the PayPal transaction information to SQL Server for fulfillment, stock management etc. PayPal provides...
9
by: laurenq uantrell | last post by:
I've gotten sort of fed up with dealing with regional date settings on the client side and am considering the following scheme - just wondering if anyone has a negative view of it or not: ...
15
by: Cesar Ronchese | last post by:
Hi, I built the sample code showing the problem with dates when viewed at different machines, different Time Zones and transported via Remoting. The zip can be downloaded here: ...
0
by: Sabotage | last post by:
Hi all, I am looking to download time zones list for my multilingual software. I found time zones list in english here:...
9
by: clintonb | last post by:
I'm looking for a way to calculate the number of days between two dates using standard C++ functions. Would it be as simple as just using the difftime() function and then dividing that result by...
4
by: Steve | last post by:
Hi All I need to compare date times from 2 different states in Australia in a Program I have which determines which way to update SQl server 2005 tables based on the lastupdate (datetime field)...
10
by: WebCM | last post by:
There is a function: http://paste.ubuntu.com/21865 It needs GMT date in YYYY-MM-DD HH:MM:SS format - in SQL: datetime. If date is the same as today, the function returns "Today". There is one...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.