PDA

Click to See Complete Forum and Search --> : Problems with date format in ASP (IIS4.0)


tompod
Nov 21st, 2000, 10:37 AM
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

Nov 21st, 2000, 12:35 PM
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:


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:


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