Date formats issue (The never ending torture)

Mehyar

Junior Contributor
Joined
Jun 9, 2003
Messages
371
Location
Lebanon
Hello all,

I will list my problem hope you dont get bored.....

I am developing a windows application that communicates with a remote sql database via a web service....


No need to mention everything, what i need is to check the time difference between the web service server and the client's application before i allow the client to connect to the webservice if there is a certain time difference i would prompt him to fix his time. The problem is that the web service is located in Boston on a PC that uses English United States as its regional settings. When the client of mine uses the same format no problem occurs, however i run into problems if my client is using the English (United Kingdom) format which uses dates as DMY and not MDY as the united states.

Can anyone help, If yes then please instruct me...

Thx in advance
 
You could use a formatted date like "12 October 2003 11:11:22" the cdate() on that always brings back correct date.
 
Thx guys for the reply..

Ok so i get my server date as a string (in USA format)

example "9/11/2003" i want to compare this date to a machine using the english format, I am using the DateDiff function..

I cannot change the server date which is a string to date because it will be interpreted as a 9 november not 11 september.

How can i solve this....
 
Don't know if there is an easier way of doing it but this shoud work.

You need the following imports

Imports System.Globalization
Imports System.Threading

then
Dim dDate As Date
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
dDate = CDate(YourDateString)
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-GB")

dDate should now be English
 
Forgot to add that you might want to check the help on the cultureinfo property as microsoft always says that 'Manipulating threads is dangerous' and I wouldn'y want you to mess up your program.
 
Pendragon, I just tried your example ...

It bloody works !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Thank you my friend I really appreciate it, It has been a long time now I was trying to solve this.

Thx a million buddy.....
 
Back
Top