Code Snips
Web Portfolio
Resume
News Finder
Katrina News
Usenet Info
EnronOffline
 
Alex Pages
Web Cam
Old Photos
Yahoo Pool
24 Predictions
Bellaire West
Our Cats
NASA & Mars
SSX High Score
Dunder-Mifflin
Office Space
 
Contact Page
 
Back ...   

VB "formatDateTime()" Function Replacement

This user-defined function emulates the formatDateTime() function in Visual Basic.

NOTE: For this function to work, you'll also need the following functions:

<%
Function formatDateTime(in_Date, strFormat)
' Convert the date presentation in different formats
' "MON_DD,_YYYY"                January 01, 2001
' "MM/DD/YYYY"                  01/01/2001
' "MM/DD/YYYY HH24:MI:SS"       01/01/2001 13:12:11
' "MM/DD/YYYY HH:MI:SS AM/PM"   01/01/2001 01:12:11 PM
' "YYYYMMDDHHNNSS"              20010101131211
' "YYYY.MM.DD.HH.NN.SS"         2001.01.01.13.12.01
' "YYYY.MM.DD"                  2001.01.01

  Dim aryMonth(12)
  Dim strDay, strMonth, strYear, strHour, strMinute, strSecond, strAMPM
  Dim temp
  
  aryMonth(0) = "Nothing"
  aryMonth(1) = "January"
  aryMonth(2) = "Feburary"
  aryMonth(3) = "March"
  aryMonth(4) = "April"
  aryMonth(5) = "May"
  aryMonth(6) = "June"
  aryMonth(7) = "July"
  aryMonth(8) = "August"
  aryMonth(9) = "September"
  aryMonth(10) = "October"
  aryMonth(11) = "November"
  aryMonth(12) = "December"
  
  If IsNull(in_Date) _ 
    Or in_Date = "" _
    Or IsNull(strFormat) _
    Or strFormat = "" Then
    temp = ""
  Else 
    Select Case strFormat
      Case "MON_DD,_YYYY"
        strDay = Day(in_Date)
        strMonth = aryMonth(Month(in_Date))
        strYear = formatYearTo4Digit(Year(in_Date))
        
        temp = strMonth & " " & strDay & ", " & strYear
      
      Case "MM/DD/YYYY"
        strDay = formatTo2Digit(Day(in_Date))
        strMonth = formatTo2Digit(Month(in_Date))
        strYear = formatYearTo4Digit(Year(in_Date))
        
        temp = strMonth & "/" & strDay & "/" & strYear
        
      Case "MM/DD/YYYY HH24:MI:SS"
        strSecond = formatTo2Digit(Second(in_Date))
        strMinute = formatTo2Digit(Minute(in_Date))
        strHour = formatTo2Digit(Hour(in_Date))
        strDay = formatTo2Digit(Day(in_Date))
        strMonth = formatTo2Digit(Month(in_Date))
        strYear = formatYearTo4Digit(Year(in_Date))
        
        temp = strMonth & "/" & strDay & "/" & _
            strYear & " " & strHour & ":" & strMinute & ":" & strSecond
      
      Case "MM/DD/YYYY HH:MI:SS AM/PM"
        strSecond = formatTo2Digit(Second(in_Date))
        strMinute = formatTo2Digit(Minute(in_Date))
        strHour = formatTo2Digit(formatHourIn12(Hour(in_Date)))
        strAMPM = amORpm(Hour(in_Date))
        strDay = formatTo2Digit(Day(in_Date))
        strMonth = formatTo2Digit(Month(in_Date))
        strYear = formatYearTo4Digit(Year(in_Date))
        
        If CInt(strHour) = 0 _
			And CInt(strMinute) = 0 _
			And CInt(strSecond) = 0 Then
          temp = strMonth & "/" & strDay & "/" & strYear & " 12:00:00 AM"
        Else 
          temp = strMonth & "/" & strDay & "/" & strYear & " " & _ 
              strHour & ":" & strMinute & ":" & strSecond & " " & strAMPM
        End If
      
      Case "YYYYMMDDHHNNSS"
        strSecond = formatTo2Digit(Second(in_Date))
        strMinute = formatTo2Digit(Month(in_Date))
        strHour = formatTo2Digit(Hour(in_Date))
        strDay = formatTo2Digit(Day(in_Date))
        strMonth = formatTo2Digit(Month(in_Date))
        strYear = formatYearTo4Digit(Year(in_Date))
        
        temp = strYear & strMonth & strDay & strHour & strMinute & strSecond
        
      Case "YYYY.MM.DD.HH.NN.SS"
        strSecond = formatTo2Digit(Second(in_Date))
        strMinute = formatTo2Digit(Month(in_Date))
        strHour = formatTo2Digit(Hour(in_Date))
        strDay = formatTo2Digit(Day(in_Date))
        strMonth = formatTo2Digit(Month(in_Date))
        strYear = formatYearTo4Digit(Year(in_Date))
        
        temp = strYear & "." & strMonth & "." & strDay & _
            "." & strHour & "." & strMinute & "." & strSecond
        
      Case "YYYY.MM.DD"
        strDay = formatTo2Digit(Day(in_Date))
        strMonth = formatTo2Digit(Month(in_Date))
        strYear = formatYearTo4Digit(Year(in_Date))
        
        temp = strYear & "." & strMonth & "." & strDay
      Case Else 
    End Select
  End If
  
  formatDateTime = temp
  
End Function



Find the latest information on the Enron Trial at EnronOffline, the once-a-day wrap up.