<% Function FormatDate(strDate, strDateFmt) dim strRet dim i dim formatBlock dim formatLength dim charLast dim charCur formatLength = len(strDateFmt) for i = 1 to formatLength + 1 ' grab the current character charCur = mid(strDateFmt, i, 1) if charCur = charLast then ' The block is not finished. Continue growing the block and iterate to the next character. formatBlock = formatBlock & charCur else ' we have a change and need to handle the previous block select case formatBlock case "mmmm" strRet = strRet & MonthName(DatePart("m",strDate),False) case "mmm" strRet = strRet & MonthName(DatePart("m",strDate),True) case "mm" strRet = strRet & right("0" & DatePart("m",strDate),2) case "m" strRet = strRet & DatePart("m",strDate) case "dddd" strRet = strRet & WeekDayName(DatePart("w",strDate,1),False) case "ddd" strRet = strRet & WeekDayName(DatePart("w",strDate,1),True) case "dd" strRet = strRet & right("0" & DatePart("d",strDate),2) case "d" strRet = strRet & DatePart("d",strDate) case "o" strRet = strRet & intToOrdinal(DatePart("d",strDate)) case "yyyy" strRet = strRet & DatePart("yyyy",strDate) case "yy" strRet = strRet & right(DatePart("yyyy",strDate),2) case "y" strRet = strRet & cInt(right(DatePart("yyyy",strDate),2)) case else strRet = strRet & formatBlock end select ' Block handled. Now reset the block and continue iterating to the next character. formatBlock = charCur end if charLast = charCur next 'i FormatDate = strRet End Function %>