format my string into a date!

andycharger

Centurion
Joined
Apr 2, 2003
Messages
152
I have a string from a textbox (request.form("date"))
Now I want to format that into a date format.

Reason I ask is when im preparing it for my SQL statement im doing this:
Visual Basic:
strDate = "# " & request.form("date") & " #"

This gives me "# 01/02/2004/ #"
However, it has problems gewtting into SQL Server like this. It seems to want it like this:
# 01 / 02 / 2004 # and not all closed up.

How can I format my string so that SQL server will take it?
 
Leave off the pound signs and format the date, as it appears you are doing, as "mm/dd/yyyy". Microsoft SQL Server does parse dates in the same fashion as Microsoft Access.
 
Formatting

Ok, so if I want to format the request.form("date") string into a valid date style (i.e. dd/mm/yyyy).
so how would I do that?
Is it something like:

Visual Basic:
FormatDate(request.form("date")), dd/mm/yyyy)
 
You should convert the String to Date format first, before format it to dd/mm/yyyy:

Format(myDate, "dd/MM/yyyy")
 
Back
Top