PC Review


Reply
Thread Tools Rate Thread

datetime conversion from UDT/GMT to localtime

 
 
=?Utf-8?B?Z2VvcmdlamV0c29u?=
Guest
Posts: n/a
 
      25th Aug 2007
Hi,

Env:
VB .net 2005 against SQLServer 2000 SP4 on Windows XP (latest SP)

Situation: My database has all date/times stored in UDT/GMT in datetime
fields in sqlserver...(I'm in USA EST, thus, GMT now is +4.00) [When daylight
savings time goes away in the fall, it will be +5.00)

My VB 2005 .net GUI application searches for 'myData' between 2 points in
time, and I convert the query request from local time to GMT before I make
the query, the query then returns the correct resultset, but of course, the
date/times are in UDT/GMT

Question: Is there a way for me to have the datetime(s) in field(s) flagged
as UDT/GMT, or some Globalization setting, property, or class I can use to
help me always display datetimes that are flagged as UDT to display in
localtime?

Example: Bill, a client, orders a widget at 7AM est, it is logged in the
database as 11AM since est is +4.00 hours over GMT

Now, when Bob, a seller, wants to view a history of all the orders he took
in his office in NYC between 2 points in time, my gui app converts his from
and to datetime requests into GMT times and queries the database

My problem is that the resultset, although correct, still shows the data in
GMT/UDT time, and Bob needs to view the data in his localized time zone
(should subtract -4.00 hours)

Any hits,clues,or examples would be greatly appreciated

--
thanks in advance,
georgejetson
 
Reply With Quote
 
 
 
 
William Vaughn
Guest
Posts: n/a
 
      25th Aug 2007
I wrote an article that might help. See
http://www.developer.com/db/article.php/10920_3695251_1.
hth

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------

"georgejetson" <(E-Mail Removed)> wrote in message
news:2C1E9DB5-3F86-4C3B-A037-(E-Mail Removed)...
> Hi,
>
> Env:
> VB .net 2005 against SQLServer 2000 SP4 on Windows XP (latest SP)
>
> Situation: My database has all date/times stored in UDT/GMT in datetime
> fields in sqlserver...(I'm in USA EST, thus, GMT now is +4.00) [When
> daylight
> savings time goes away in the fall, it will be +5.00)
>
> My VB 2005 .net GUI application searches for 'myData' between 2 points in
> time, and I convert the query request from local time to GMT before I make
> the query, the query then returns the correct resultset, but of course,
> the
> date/times are in UDT/GMT
>
> Question: Is there a way for me to have the datetime(s) in field(s)
> flagged
> as UDT/GMT, or some Globalization setting, property, or class I can use to
> help me always display datetimes that are flagged as UDT to display in
> localtime?
>
> Example: Bill, a client, orders a widget at 7AM est, it is logged in the
> database as 11AM since est is +4.00 hours over GMT
>
> Now, when Bob, a seller, wants to view a history of all the orders he took
> in his office in NYC between 2 points in time, my gui app converts his
> from
> and to datetime requests into GMT times and queries the database
>
> My problem is that the resultset, although correct, still shows the data
> in
> GMT/UDT time, and Bob needs to view the data in his localized time zone
> (should subtract -4.00 hours)
>
> Any hits,clues,or examples would be greatly appreciated
>
> --
> thanks in advance,
> georgejetson


 
Reply With Quote
 
WenYuan Wang [MSFT]
Guest
Posts: n/a
 
      27th Aug 2007
Hello Georgejetson,
Thanks for William's great article. This way could be used for any timezone.

According to your description, it seems what you need is to convert the
Datatime from GMT to localized time zone. (If I misunderstood anything,
please correct me.)

Datetime.Parse method converts the specified string representation of a
date and time to its DateTime equivalent. We need to add "GMT" at the end
of string. Thereby, Parse method could recognize the GMT string.

Dim timeGMT As String = "8/27/2007 6:26:26 PM"
timeGMT += " GMT"
'Now,timeGMT is "8/27/2007 6:26:26 PM GMT".
Dim time As System.DateTime = System.DateTime.Parse(timeGMT)
System.Console.WriteLine(time)

Hope this helps. Please let me know if this is what you need. I'll follow
up. We are glad to assist you. Have a great day.
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
WenYuan Wang [MSFT]
Guest
Posts: n/a
 
      29th Aug 2007
Hello georgejetson,

This is Wen Yuan again. I haven't heard from you about a couple of days.
I just want to check if you have resolved the issue so far?
If the issue still persists, please don't hesitate to update here. We are
glad to assist you.

Have a great day,
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      3rd Sep 2007
Hi georgejetson,

Have you seem above replies to your question? We're about to close this
post. Please feel free to let us know if you have any concerns or
questions. Thanks.


Regards,
Walter Wang ((E-Mail Removed), remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
=?Utf-8?B?Z2VvcmdlamV0c29u?=
Guest
Posts: n/a
 
      25th Oct 2007
Thanks for all your help,

I ended up creating a userdefinedfunction that accepts as input a datetime,
and, returns the datetime back in localtime, all my views now use this
function for the clients

thanks again,

george jetson
--
thanks in advance,
georgejetson


""Walter Wang [MSFT]"" wrote:

> Hi georgejetson,
>
> Have you seem above replies to your question? We're about to close this
> post. Please feel free to let us know if you have any concerns or
> questions. Thanks.
>
>
> Regards,
> Walter Wang ((E-Mail Removed), remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
datacolumn datetime from UTC to Localtime georgejetson Microsoft ADO .NET 2 7th Mar 2008 09:03 AM
Conversion of .NET DateTime to SQL datetime via VarBinary Karch Microsoft ADO .NET 1 24th Mar 2007 02:30 PM
DateTime conversion to its sqlServer datetime float representation. A.Neves Microsoft C# .NET 1 20th Apr 2006 01:01 PM
Tell DateTime to use different time zone as LocalTime? Randall Parker Microsoft C# .NET 1 19th Dec 2005 01:43 PM
XML dateTime conversion to DateTime.MinValue accross timezones Symon R Microsoft Dot NET 0 6th Aug 2003 07:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:55 AM.