Last post Mar 01, 2007 11:03 PM by RobertJJ
Mar 01, 2007 12:04 AM|RobertJJ|LINK
I have a problem to write a date in an Access database using a FormAndDatePicker control.
When I write a date in a local database all function fine but, after the publication of the Site the date is always written in an USA format (mm/gg/yyyy ).
When I write into a database I use the following declartion:
Dim ST As Date = Format(CType(FormView1.FindControl("dtpicker"),_ DateandTimePicker).selectedDateTime, "dd/MM/yyyy HH.mm.ss")
Moreover I force the page to be in Italian format:
<%@ Page Language="VB" Culture="it-IT" UICulture="it" %>
There is a method to set all the dates in european format? Perhaps into a Web.Config?
Mar 01, 2007 01:51 AM|SGWellens|LINK
In your Access database, is the date field a date/time field, or is it a text field?
If it is a date/time field, good.
I believe Access will display the date/time according to the regional settings of the local computer.
If your computer is setup as Italian, and mine is setup as United States. we could look at the same date and see two different formats of the same information.
Mar 01, 2007 10:35 AM|RobertJJ|LINK
Thank you for the speed answer.
My Access DB has a date/time field but the problem is that if I write a date in the local db (that has the same structure as the remote) the date is written in correct way (Italian). If I write the date in a remote DB that’s written in a USA format.
Obviously the Provider has the settings in USA format.
Example: I write a date 2 March 2007.
Into the field local is written 02.03.2007 but in the remote is written 03.02.2007 so that, when I go to read in the remote DB the date displayed is 3 February (wrong!)
I know that depends by the regional settings but I don’t know which is the way to force an Italian date into an USA environment.
I thank you in advance for the welcome answer.
Mar 01, 2007 03:51 PM|SGWellens|LINK
I’m not sure what you mean by local DB and remote DB.
If you are letting users enter dates in a “numerical” format you may have this problem:
Say Italian dates are dd/mm/yy
Say U.S. dates are mm/dd/yy
If I’m on an Italian system, there is nothing to stop me from entering "02/03/07" for Feb 3. The Italian system will correctly interpret it as Mar 2.
Mar 01, 2007 04:41 PM|RobertJJ|LINK
A local DB is a DB in my develop Computer in my Office.
A remote DB is a DB into the computer of my Provider. I don’t know where it is.
I enter the date without errors but the dates are written in 2 different ways so that when I read these dates they represent 2 different dates.
Mar 01, 2007 05:04 PM|SGWellens|LINK
How does the user enter the date?
Could you show the asp code of the control used?
Mar 01, 2007 11:03 PM|RobertJJ|LINK
I answer by myself.
The solution is that we must use parameters instead of the command string. In that way all function fine either local or remote DB.
Cmd.Parameters.Add("@p1",OleDB.OleDbType.Date).Value = ST
where ST contains the data.