F
francois
hi,
I have an ASP.NET application with a piece of code that looks like this:
(it is a VB.NET snippet)
Thread.CurrentThread.CurrentCulture = New
CultureInfo(Session.Item("Culture").ToString)
Thread.CurrentThread.CurrentUICulture = New
CultureInfo(Session.Item("Culture").ToString)
Dim cultureSpecificDate As Date = Request.QueryString("date").Trim()
the QueryString object is a key-value collection type, (similar to a
hashtable). It is a NameValueCollection to be exact, but I believe that this
is not an important point.
Let say the string returned by Request.QueryString("date").Trim() is
"20/7/2004 0:00:00"
If the culture loaded at that time is: english then the Date object created
will contain a correct value which is 20/7/2004. But if the culture loaded
is a bit exotic, like the thai culture (which i believe follows a budhist
calendar type), the date object created will be 7/20/1461
That is a problem as later on that date will be used for some SQL commands
and look for that related to the date 20th of july 1461 which obviously does
not exist as the year is tottally different (543 years of difference).
Then I have 2 questions:
1. how can i solve this and always have the right date? (2004 for my SQL
stored procedure). Also I would like a generic solution that will work for
any culture. I would like to avoid any hardcoded date transformation.
2. 2004 in the thai calender correspond 2547 (2004 + 543 = 2547)
Then it seems that when the date object instance is created there is a
problem as it transform 2004 into 1461 (2004 -543 = 1461), which basically
is wrong.
Best regards and tx in advance,
Francois
I have an ASP.NET application with a piece of code that looks like this:
(it is a VB.NET snippet)
Thread.CurrentThread.CurrentCulture = New
CultureInfo(Session.Item("Culture").ToString)
Thread.CurrentThread.CurrentUICulture = New
CultureInfo(Session.Item("Culture").ToString)
Dim cultureSpecificDate As Date = Request.QueryString("date").Trim()
the QueryString object is a key-value collection type, (similar to a
hashtable). It is a NameValueCollection to be exact, but I believe that this
is not an important point.
Let say the string returned by Request.QueryString("date").Trim() is
"20/7/2004 0:00:00"
If the culture loaded at that time is: english then the Date object created
will contain a correct value which is 20/7/2004. But if the culture loaded
is a bit exotic, like the thai culture (which i believe follows a budhist
calendar type), the date object created will be 7/20/1461
That is a problem as later on that date will be used for some SQL commands
and look for that related to the date 20th of july 1461 which obviously does
not exist as the year is tottally different (543 years of difference).
Then I have 2 questions:
1. how can i solve this and always have the right date? (2004 for my SQL
stored procedure). Also I would like a generic solution that will work for
any culture. I would like to avoid any hardcoded date transformation.
2. 2004 in the thai calender correspond 2547 (2004 + 543 = 2547)
Then it seems that when the date object instance is created there is a
problem as it transform 2004 into 1461 (2004 -543 = 1461), which basically
is wrong.
Best regards and tx in advance,
Francois