A (hopefully) final post, in case anyone ever searches through for this problem again.
Using Dreamweaver, I was having the same problem with the contents of input areas in forms updating the Access database. As above, a date like 11 July 2007 (11/07/2006) would flip from dd/mm/yyyy to mm/dd/yyyy and back again each time it was pulled from the database into an update page and when the form was submitted to amend the database.
One of the other links in my last post led to a couple of short functions (which look similar to Daemonspyre and WilliamHolmes) posted by Mat41 on the
Wrox P2P forum:
Code:
<%
function ddmmyyyy(varDate)
ddmmyyyy = Day(DateValue(varDate)) & "/" & Month(DateValue(varDate)) & "/" & Year(DateValue(varDate))
end function
function mmddyyyy(varDate)
mmddyyyy = Month(DateValue(varDate)) & "/" & Day(DateValue(varDate)) & "/" & Year(DateValue(varDate))
end function
%>
So ddmmyyyy(now) returns the date in dd/mm/yyyy format, and mmddyyyy(now) returns it in mm/dd/yyyy format.
On a hunch (well, less of a hunch and more because the software's default is almost certainly to be the US mm/dd/yyyy format), I though that if I could take a date that was in dd/mm/yyyy format and force it into mm/dd/yyyy format before insertion into the database, then there would be no reason for the date flip to ever occur.
First I applied the ddmmyyyy function to the text in the input field:
Code:
<input name="DateStart" type="text" id="DateStart" title="Enter the start date" value="<%=ddmmyyyy((rsCourse.Fields.Item("DateStart").Value))%>" />
(rsCourse is the recordset name and DateStart the name of the date field in the table)
Knowing that the date was being pulled out and displayed in a consistent way, I then modified the upload code. The line that updates the table in this particular case was:
Code:
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 135, 1, -1, MM_IIF (Request.Form("DateStart"), Request.Form("DateStart")), null) ' adDBTimeStamp
Which I modified to:
Code:
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 135, 1, -1, MM_IIF(mmddyyyy(Request.Form("DateStart")), mmddyyyy(Request.Form("DateStart")), null)) ' adDBTimeStamp
So that I know that the content of the input field would be uploaded to the server consistently in mm/dd/yyyy format.
Hope this helps anyone tearing their hair out who comes after me. Obviously, credit to
mat41 from Wrox for the original VBScript function which is completely portable and now safely saved for use as an include file in the site I'm currently working on.