Forums
This topic is locked
asp - access - date problems with oledb - SOLUTION
04 Feb 2010 18:27:39 MX Addict posted:
Solution for date format problems with olebd connectionstring and Dreamweaver insert/update behaviour:example:
01-02-2010 [1 february 2010] becomes 02-01-2010 [2 january 2010] when insert/update this to access database
< %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 %>
Form
<input type="text" name="field" id="field" value="<%=ddmmyyyy((recordset1.Fields.Item("date").Value))%>" />
DW insert/update behaviour
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 135, 1, -1, MM_IIF(mmddyyyy(Request.Form("DateStart")), mmddyyyy(Request.Form("DateStart")), null)) ' adDBTimeStamp
Credits to:
www.codingforums.com/showthread.php?t=117190
If someone knows a better solution. Be my Guest
Edited by - MX Addict on 04 Feb 2010 18:33:42
Replies
Replied 04 Feb 2010 20:06:15
04 Feb 2010 20:06:15 Patrick Julicher replied:
Hi,
The best solution I've seen so far. Thanks!
Kind regards, Patrick
The best solution I've seen so far. Thanks!
Kind regards, Patrick
Replied 05 Feb 2010 19:00:27
05 Feb 2010 19:00:27 MX Addict replied:
Hi Patrick,
It seems that the code above does not work in combination with the PAU extension. Do you know a solution. I get an error:
Runtimefout Microsoft VBScript (0x800A01C2)
Thanks
It seems that the code above does not work in combination with the PAU extension. Do you know a solution. I get an error:
Runtimefout Microsoft VBScript (0x800A01C2)
Thanks
Replied 19 Sep 2012 14:33:21
19 Sep 2012 14:33:21 RVL webdesignstudio replied:
OK, I found a quick and dirty workaround, which is basically not to submit the field as a date.
You needed to change this line of code:
with this:
The difference being these parameters: "135, 1, -1" becomes "202, 1, 150".
I can't a find a reference for this at Adobe but the third must be the length of the string, the first the type of
data (e.g. text variables, number, date) and the middle one, I'm not sure...
If the first of these parameters could be adjusted to the correct date type, that would be the right solution, but I don't know if this is possible.
Anyway, this workaround worked for me - provided there is sufficient validation on the form to pick up invalid date formats.
You needed to change this line of code:
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 135, 1, -1, MM_IIF(UploadFormRequest("article_date_updated"), UploadFormRequest("article_date_updated"), null)) ' adDBTimeStamp
with this:
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 150, MM_IIF(UploadFormRequest("article_date_updated"), UploadFormRequest("article_date_updated"), null)) ' adDBTimeStamp
The difference being these parameters: "135, 1, -1" becomes "202, 1, 150".
I can't a find a reference for this at Adobe but the third must be the length of the string, the first the type of
data (e.g. text variables, number, date) and the middle one, I'm not sure...
If the first of these parameters could be adjusted to the correct date type, that would be the right solution, but I don't know if this is possible.
Anyway, this workaround worked for me - provided there is sufficient validation on the form to pick up invalid date formats.