Results 1 to 2 of 2

Thread: Problems with date format in ASP (IIS4.0)

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Slovenia
    Posts
    40
    Hi
    I have problem with date format in ASP.
    Date format in ASP is different then Short Date Style in Regional settings in operating system.

    Short Date Style in regional settings = 'DD.MM.YYYY'
    ASP date format: 'DD.MM.YY'

    Is this Y2K problem (Option pack 4.0)?
    I'm using WIN NT Server4.0 platform with SP6 installed
    and IIS4.0 (option pack 4.0).

    If I install the same Option Pack in WIN NT 4.0 Workstation,
    then date format in ASP is the same as in regional settings.

    Can someone help me?
    Best regards,
    Tomaz

  2. #2
    Guest
    I can't answer your questions about option paks and updates but I can offer a work-around.

    What you could do is build your own date formatting function using the Day(), Month(), and Year() functions.

    It might look something like this:

    Code:
    Function FormatDate(dteDateValue, blnFourDigitYear)
      Dim strDay
      Dim strMonth
      Dim strYear
      
      strDay = Day(dteDateValue)
      If Len(strDay) = 1 Then
        strDay = "0" & strDay
      End If
      
      strMonth = Month(dteDateValue)
      If Len(strMonth) = 1 Then
        strMonth = "0" & strMonth
      End If
      
      strYear = Year(dteDateValue)
      If Not blnFourDigitYear Then
        strYear = Mid(strYear, 3, 2)
      End If
      
      FormatDate = strMonth & "/" & strDay & "/" & strYear
      
    End Function
    And use it like:

    Code:
    Response.Write "<P>" & FormatDate(Date, True) & "</P>" & vbcrlf
    Response.Write "<P>" & FormatDate(Date, False) & "</P>" & vbcrlf
    This function produces dates formatted in either mm/dd/yy or mm/dd/yyyy formats regardless of system settings. You can change the date delimitter from '/' to whatever you like within the function code.

    Cheers,
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width