This is a forum where members new and old can come to ask questions and get info and opinions. It is not a place to advertise your business or have other forms of advertising, whether it be in your posts or signature.

All links in the forum will not be indexed by Search Engines and any unapproved forms of advertising or spam will be dealt with accordingly, deleted, and that member's account banned.

Forums

Overview » ASP » asp - access - date problems with oledb - SOLUTION
Reply

asp - access - date problems with oledb - SOLUTION

MX Addict
Wicked Member



Since: 06 Feb 2003
Posts: 245
Posted 04 Feb 2010 18:27:39

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

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
Patrick Julicher
Official Representative



Since: 04 Feb 2002
Posts: 1,208
Replied 04 Feb 2010 20:06:15
Hi,

The best solution I've seen so far. Thanks!

Kind regards, Patrick
MX Addict
Wicked Member



Since: 06 Feb 2003
Posts: 245
Replied 05 Feb 2010 19:00:27
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

Reply to this topic

Message
Reply
Follow us on Facebook Follow us on twitter Subscribe to the RSS feed
Activate your free membership today | Login | Currency