"David" <da*********@scene-double.co.ukwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
Hi,
I have a form which is posting a user entered date to an asp page.
The date is then used in a SQL string.
The format of the date is received as dd/mm/yyyy, with the user typing
the '/' as well
how can I convert it to yyyy-mm-dd
----------------
I have tried this, but I think I need to strip out the '/' ??, as it is
not working
D1 = cdate(request.form("date"))
strDay = Day(D1)
strMonth = Month(D1)
strYear = Year(D1)
NewstrDate = strYear & "-" & strMonth & "-" & strDay
Appreciate your help, thanks so much :-)
You almost had it - you need to use the Split() function:
<%
Function changeUserDate(userDate)
temp = Split(userDate,"/")
strDay = temp(0)
strMonth = temp(1)
strYear = temp(2)
changeUserDate = strYear & "-" & strMonth & "-" & strDay
End Function
Response.Write changeUserDate(Request.Form("date"))
%>
Personally, I use a javascript calendar so that users can select dates for
forms. That way I can manage the format of the input and don't have to do
anything with it serverside, except check it's there (and check that end
dates come after start dates etc...).
There are a number of these knocking about on javascript code sites. Google
will find one for you easily enough.
--
Mike Brind