changing date format in the european way using asp
Hello.
I would like to know how to change the date format in the european way using asp and data assist.
I saw there is an answer for php, but i didn't find out the same for asp.
Thanks.
Marco
Hello.
I would like to know how to change the date format in the european way using asp and data assist.
I saw there is an answer for php, but i didn't find out the same for asp.
Thanks.
Marco
Here is a function called switchMonthDay() which can be used on any value that you pass into WA Data Assist to enable international date formats to be used. Here's the ASP VBScript version of the function:
<%
function switchMonthDay(theDate)
dim theMonth,theDay,theYear
theMonth = Left(theDate,inStr(theDate,"/")-1)
theYear = Right(theDate, Len(theDate) - inStrRev(theDate,"/"))
theDay = Mid(theDate,inStr(theDate,"/")+1, inStrRev(theDate,"/")-inStr(theDate,"/")-1)
switchMonthDay = theDay & " / " & theMonth & " / " & theYear
end Function
%>
Just add this function to the top of your page just after the include lines in the code. Then when you set up your server behaviors just wrap the value you wish to format in the switchMonthDay() function call:
<%=switchMonthDay(request.Form("dateField))%>
Thanks, i knew this function and it worked well with data assist 1, but now i have problems with data assist 2.
Could you help me?
Where do i have to insert it exactly? Could you write me an example?
Regards,
Marco
Here is an example of the function in action.
In this example we will be trying to put this around the date field:
WA_fieldValuesStr = "" & cStr(cStr(Request.Form("OrderReferenceID"))) & "" & "|" & "" & cStr(cStr(Request.Form("OrderVisitorID"))) & "" & "|" & "" & cStr(cStr(Request.Form("OrderShipping"))) & "" & "|" & "" & cStr(cStr(Request.Form("OrderTax"))) & "" & "|" & "" & cStr(cStr(Request.Form("OrderTotal"))) & "" & "|" & "" & cStr(cStr(Request.Form("OrderDate"))) & "" & "|"
So the code for the date field should be updated to look like this:
switchMonthDay(cStr(cStr(Request.Form("OrderDate")))) & "" & "|"
This code was taken from a DataAssist insert. I think it will do what you are looking for, please let us know if there are any problems with it.
I received an error message. I attach you the files and the error message.
I'm not sure why you are getting this error message. It looks to be saying that the Left has an invalid argument or something like that. I have created a sample test page for you. Please load this page to your testing server and test the page. You should see a date, then the date with the switch applied to it. Please let me know your result.
Oops, I forgot the file, here it is.
Yes, i see as you said, the date and the switched date. Maybe i made something wrong about the other function? I put, in the field "value" of the datassist search behaviour, this function: <%=switchMonthDay(Request.Form("S_data"))%> , Is it right?
The reference you posted looks correct, but if you are getting an error with it then there may be a problem. You should take a look at the code on the sample page and look to see if this is how you are using the function. If it is used in the same way you should have the same result. Please post back and let me know specifically the result you are getting if it is not working correctly for you.
... It seems that's all right, i don't know what's happening... Could you check the attached files in the previous message?... Is it right: <%=switchMonthDay(Request.Form("S_data"))%> or <%=switchMonthDay(cStr(Request.Form("S_data")))%> ?
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.