close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

changing date format in the european way using asp

Thread began 9/29/2009 5:08 am by info259249 | Last modified 10/27/2009 6:33 pm by Eric Mittman | 5581 views | 14 replies |

info259249

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

Sign in to reply to this post

Eric Mittman

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))%>
Sign in to reply to this post

info259249

problems with data assist 2

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

Sign in to reply to this post

Eric Mittman

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.

Sign in to reply to this post

info259249

error

I received an error message. I attach you the files and the error message.

Attached Files
file_dataassist.zip
Sign in to reply to this post

Eric Mittman

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.

Sign in to reply to this post

Eric Mittman

Oops, I forgot the file, here it is.

Attached Files
switch_month_day.zip
Sign in to reply to this post

info259249

right result

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?

Sign in to reply to this post

Eric Mittman

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.

Sign in to reply to this post

info259249

...

... 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")))%> ?

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

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.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...