Forums
This topic is locked
ASP Upload 3 and dates
Posted 02 Oct 2007 15:17:35
1
has voted
02 Oct 2007 15:17:35 John Dixon posted:
I have a problem with Access databases and dates swapping between American and British formatted dates. Basically for dates entered, if the first figure is less than 13, the date and month are transposed, so 01/10/2007 (1 October 2007) gets saved as 10/01/2007 (1 January 2007), but 13/10/2007 is reliably saved as 13 October 2007.I have a short VBScript:
<pre id=code><font face=courier size=2 id=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
function yyyymmdd(varDate)
yyyymmdd = Year(DateValue(varDate)) & "/" & Month(DateValue(varDate)) & "/" & Day(DateValue(varDate))
end function
%></font id=code></pre id=code>
Which I use in combination with the Insert or Update behaviour with Dreamweaver. A line in the insert behaviour that reads:
<pre id=code><font face=courier size=2 id=code>MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 135, 1, -1, MM_IIF(Request.Form("DateStart"), Request.Form("DateStart"), null) ' adDBTimeStamp</font id=code></pre id=code>
would be replaced with
<pre id=code><font face=courier size=2 id=code>MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 135, 1, -1, MM_IIF(mmddyyyy(Request.Form("DateStart"), mmddyyyy(Request.Form("DateStart"), null)) ' adDBTimeStamp</font id=code></pre id=code>
So this takes the date which has been entered in dd/mm/yyyy format and converts it to the American mm/dd/yyyy format before inserting it into the database.
However Pure ASP Upload 3 replaces the Request.Form command with UploadFormRequest:
<pre id=code><font face=courier size=2 id=code>MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 135, 1, -1, MM_IIF(UploadFormRequest("DateStart", UploadFormRequest("DateStart", null)) ' adDBTimeStamp</font id=code></pre id=code>
which, as per my example above, I've tried to convert into an American format date by using
<pre id=code><font face=courier size=2 id=code>MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 135, 1, -1, MM_IIF(mmddyyyy(UploadFormRequest("DateStart"), mmddyyyy(UploadFormRequest("DateStart", null))) ' adDBTimeStamp</font id=code></pre id=code>
I'm getting a Type Mismatch error as (I think) the content of the text box in my form is converted to a string which can't then be picked apart as a date and put together again. Anyone got any ideas as to how I can fix this?
Edited by - dpages on 02 Oct 2007 15:19:48
Edited by - dpages on 02 Oct 2007 15:24:06