Forums

This topic is locked

Date format with MS Access

Posted 05 Nov 2001 17:04:11
1
has voted
05 Nov 2001 17:04:11 François Chenuz posted:
Hello

I have Dreamweaver Ultra Dev 4 and a Data Base MS Access 97
I will insert in a data base MS Access a field with a date (french date dd.mm.yyyy), but when the date is false, the date is reversed.
Field:
Nom text format
Prénom text format
date_nais date format


For example:
When I type 31/02/01(31 february 2001) in my insert page, the date in the MS Access data base become 01.02.31 (1 february 1931).
How can I have a control of the date in Ultra Dev, when the date is false or not the right format.
Thank you very match for your help
François


Here is my code from my insert page:
<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file= »Connections/Sortie.asp » -->
<%
// *** Edit Operations: declare variables
// set the form action variable var MM_editAction = Request.ServerVariables(« URL »; if (Request.QueryString) { MM_editAction += « ? » + Request.QueryString;
}

// boolean to abort record edit
var MM_abortEdit = false;

// query string to execute
var MM_editQuery = « »;
%>
<%
// *** Insert Record: set variables
if (String(Request(« MM_insert ») != « undefined » {
var MM_editConnection = MM_Sortie_STRING; var MM_editTable = « tblAdresse »; var MM_editRedirectUrl = « affichage.asp»; var MM_fieldsStr = « textnom|value|textprenom|value|textdatenais|value »; var MM_columnsStr = « nom|’,none, »|prénom|’,none, »|date_nais|#,none,NULL »;
// create the MM_fields and MM_columns arrays var MM_fields = MM_fieldsStr.split(« | »; var MM_columns = MM_columnsStr.split(« | »;
// set the form values
for (var i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = String(Request.Form(MM_fields[i]));
}

// append the query string to the redirect URL
if (MM_editRedirectUrl && Request.QueryString &&
Request.QueryString.length > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf(&#8216;?&#8217<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle> == -1)? »? »: »& »
&#61623; Request.QueryString;
}
}
%&gt;
&lt;%
// *** Insert Record: construct a sql insert statement and execute it
if (String(Request(« MM_insert ») != « undefined » {
// create the sql insert statement
var MM_tableValues = « », MM_dbValues = « »;
for (var i=0; i+1 &lt; MM_fields.length; i+=2) {
var formVal = MM_fields[i+1]; var MM_typesArray = MM_columns[i+1].split(« , »;
var delim = (MM_typesArray[0] != « none » ? MM_typesArray[0] : « »;
var altVal = (MM_typesArray[1] != « none » ? MM_typesArray[1] : « »;
var emptyVal = (MM_typesArray[2] != « none » ? MM_typesArray[2] : « »; if (formVal == « » || formVal == « undefined » { formVal = emptyVal;
} else {
if (altVal != « » {
formVal = altVal;
} else if (delim == « &#8217; » { // escape quotes
formVal = « &#8217; » + formVal.replace(/&#8217;/g, » » » + « &#8217; »;
} else {
formVal = delim + formVal + delim;
}
}
MM_tableValues += ((i != 0) ? « , » : « » + MM_columns[i];
MM_dbValues += ((i != 0) ? « , » : « » + formVal;
}
MM_editQuery = « insert into « + MM_editTable + « (« + MM_tableValues + « ) values (« + MM_dbValues + « ) »;
if (!MM_abortEdit) {
// execute the insert var MM_editCmd = Server.CreateObject(&#8216;ADODB.Command&#8217<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>;
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();
if (MM_editRedirectUrl) {
Response.Redirect(MM_editRedirectUrl);
}
}

}
%&gt;
&lt;%
var Affichage = Server.CreateObject(« ADODB.Recordset »;
Affichage.ActiveConnection = MM_Sortie_STRING;
Affichage.Source = « SELECT * FROM tblAdresse »;
Affichage.CursorType = 0;
Affichage.CursorLocation = 2;
Affichage.LockType = 3;
Affichage.Open(); var Affichage_numRows = 0;
%&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv= »Content-Type » content= »text/html; charset=iso-8859-1 »&gt;
&lt;/head&gt;
&lt;body bgcolor= »#FFFFFF » text= »#000000 »&gt;
&lt;form name= »form1 » method= »POST » action= »&lt;%=MM_editAction%&gt; »&gt;
&lt;p&gt;
&lt;input type= »text » name= »textnom »&gt;
Nom&lt;/p&gt;
&lt;p&gt;
&lt;input type= »text » name= »textprenom »&gt;
Pr&eacute;nom &lt;/p&gt;
&lt;p&gt;
&lt;input type= »text » name= »textdatenais »&gt;
Date de naissance&lt;/p&gt;
&lt;p&gt;
&lt;input type= »submit» name=»Submit » value= »Ajout »&gt;
&lt;/p&gt;
&lt;input type= »hidden » name= »MM_insert » value= »true»&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;%
Affichage.Close();
%&gt;


Replies

Replied 06 Nov 2001 16:51:20
06 Nov 2001 16:51:20 Ricardo Ribeiro replied:
I have the same problem here. It would be cool if I could pick up the solution for this problem here in these foruns.

Reply to this topic