english and spanish format mixture

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a VB.NET App and Access DB(Spanish), Win XP(Spanish) .. I have notice
that for some operation (insert..etc)I need to set the format of dates to
english and sometime I need to ser the format of dates to Spanish so in order
to the program run well for every function I have to mix the formats, It is
not logical

What is the best practice to setup once the dates in a application?

Ken
 
Hi Ken,

It is not clear to me what you are trying to do. You can use CurrentCulture
to output dates in the language format of the current culture settings of
the operating system.

Do you mean your application might run on an English or on a Spanish
operating system, or do you mean that the program may communicate with other
software (like databases) that may report dates in different formats?

Happy Coding!
Morten Wennevik [C# MVP]
 
Hi

I´m going to deploy the software on machines with english and spanish SO
(But that depend on me so should I setup all the computers to have a unique
SO?)

and the problem is that I'm using a DBAccess(Spanish), I need to
Select,Insert, Update and Delete data using Dates as a parameters in my
querys. I´m using the next format in most of the dates instructions:


'Dim Format As New System.Globalization.CultureInfo("en-US", True)
Dim Format As New System.Globalization.CultureInfo("es-VE", True)
DateTime.Parse(DTFecha.Value.ToShortDateString, Format)

I´m using also DateTime.Today or DateTime.Now without format because it work
fine sometimes

for some dates the english format works good but not for others dates and in
those cases I have to change the culture.

I think is not logical to try all my querys with every single day in order
to test, so now I dont now what line to follow

Ken
 
Ken,

I still can't really say what is the best solution, and my advices might not
be the best for your case, but I would probably stick with a common date
format in the database.

Is your program the only one accessing the database? If so, it does not
matter what format you store it in as long as read it in the same format.

What do you mean by some english dates being fine?

Use SqlParameter/OleDbParameter in your queary if you haven't already, and
use one of the date/time databasetypes. Use CurrentCulture when outputting
and parsing datetime (or give the option to select language).

Happy Coding!
Morten Wennevik [C# MVP]

Ken said:
Hi

I´m going to deploy the software on machines with english and spanish SO
(But that depend on me so should I setup all the computers to have a
unique
SO?)

and the problem is that I'm using a DBAccess(Spanish), I need to
Select,Insert, Update and Delete data using Dates as a parameters in my
querys. I´m using the next format in most of the dates instructions:


'Dim Format As New System.Globalization.CultureInfo("en-US", True)
Dim Format As New System.Globalization.CultureInfo("es-VE", True)
DateTime.Parse(DTFecha.Value.ToShortDateString, Format)

I´m using also DateTime.Today or DateTime.Now without format because it
work
fine sometimes

for some dates the english format works good but not for others dates and
in
those cases I have to change the culture.

I think is not logical to try all my querys with every single day in order
to test, so now I dont now what line to follow

Ken



Morten Wennevik said:
Hi Ken,

It is not clear to me what you are trying to do. You can use
CurrentCulture
to output dates in the language format of the current culture settings of
the operating system.

Do you mean your application might run on an English or on a Spanish
operating system, or do you mean that the program may communicate with
other
software (like databases) that may report dates in different formats?

Happy Coding!
Morten Wennevik [C# MVP]
 
hi I hope to explain myself very well this time

My SO: Win XP Spanish
My DB: Access 2000 Spanish
My Regional Config: Spanish
I'm the only one saving and retriving data from the DB, I don't have
problems showing data but retrieving data via Select

On my DB Access
----------------------
Date format: Fecha general 19/06/1994 05:34:23 p.m.

On the DB the dates are being saved like this (dd/MM/yyyy)

24/11/2004 08:26:10 a.m.
03/11/2004 01:42:02 p.m.

good!

-----------------------------------
At this time I have to switch between two cultures in order to run my select
on every date of the month

Public Formato As New System.Globalization.CultureInfo("es-VE", True)
Public Formato As New System.Globalization.CultureInfo("en-US", True)

this is an extract from my selects:

Where FechaSorteo = #" &
DateTime.Parse(DTPickerDate.Value.ToShortDateString(), Formato) & "#"
Where FechaSorteo = #" & DateTime.Parse(DateTime.Today.ToShortDateString(),
Formato) & "#"

good!
------------------------------------
When I run my selects on the following dates , this is what happends

24/11/2004 08:26:10 a.m.
with Format in spanish: Good!
with Format in english: The string can not be recognized as a valid DateTime

03/11/2004 01:42:02 p.m.
with Format in spanish: Return nothing
with Format in english: Good!

-------------------------------------
I notice that:

I have to use English Culture from 01/11/2004 to 12/11/2004
and spanish Culture from 13/11/2004 to 30/11/2004

I dont know how to fix it

Ken
 
Back
Top