in message : In ASP, how can I format a date that's in the form of dd/mm/yyyy to
: yyyy-mm-dd?
:
: I know about the FormatDateTime function, but as far as I can tell, this
: function won't allow me to customize exactly how I want the date
formatted.
http://kiddanger.com/lab/dateformat.asp
<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True
sub prt(str)
Response.Write(str & vbCrLf)
end sub
function formatDate(str)
'yyyy-mm-dd
dim i, arr ' m/d/yyyy
arr = split(str,"/")
for i = 0 to 1
if len(arr(i)) = 1 then
arr(i) = "0" & arr(i)
end if
next
formatDate = arr(2) & "-" & arr(0) & "-" & arr(1)
end function
dim d
d = DateSerial(year(now()),month(now()),day(now()))
prt(d & " has been formatted as " & formatDate(d))
%>
HTH...
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center -
http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library -
http://msdn.microsoft.com/library/default.asp