On the original post
Is the field your operating on a datefield in the database? If that is the case then the format your seeing that data in the database is meaningless. It is passed as some sort of DateTime ovalue to the SQL driver that your using to talk ot the database, that driver than converts it into a value understandable by the Recordset object, which then delievers it to your code in a way that is understand in VBScript as a DateTime variable. You can use all of the Date/Time functions on it you want and printing it wihtout using a format function should result in a LongDate format.
My guess is your not seeing that long date format, meaning tat either your data is stored as text or that your database driver doesn't know how to present that data as a date to VBS.
- First thing to try is DNG's first thought. See if you can do the conversion in your SQL statement and let the Database handle it.
- Second thing to try is similar to DNG's second suggestion, but not as innefficient (sorry). Concatenations cost in VBS, especially if your doing a lot of them. You could use the same Mid() and Left() functions that DNG did but feed them into a DateSerial(
year,
month,
day) function call.
As far as formatting is concerned, you can use the FormatDateTime function to output a shortdate (theformat your looking for).
A google on any of these function names and "ASP" should get you a function reference for them for more info on how they work or what values they expect.
On Response.Write vs <%=var%>
Using an = is the same thing as Response.Write, it's just a shorthand method. The performance hits are more likely to come from multiple Response.Write's and/or string concatenation versus a single block of HTML with a single =/Response.Write.
Example:
Code:
'2 string concats and a write
Response.Write "<input type=""text"" name=""bob"" value=""" & myVar & """>"
'3 writes
Response.Write "<input type=""text"" name=""bob"" value="""
Response.Write myVar
Response.Write """>"
'1 block of HTML, 1 write
%><input type="text" name="bob" value="<%=myVar%>"><%
I don't remember the efficiency numbers, but at some point it actually becomes more efficient to write code in a block of HTML than it does to Response.Write it. There is some efficiency loss going back and forth alot, but for large chunks of HTML (especially with only an occasional ASP variable output) it's actually better to escape out of the ASP block and dump it all in a large HTML block.
-T