J
jethro_uk
Hi all,
I'm having a hard time with the Day() function. Basically, it appears
to be picking and choosing which part of a date string it uses to
return the result ...
heres some code :
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<%
Function formatDate(dDate)
formatDate=""
If IsNull(dDate) or Trim(dDate)="" Then
Else If IsDate(dDate) Then
If dDate<CDate("January 1, 1901") Then
formatDate=" - - "
Else formatDate=Day(dDate) & " " & MonthName(Month(dDate), true) &
" " & year(dDate)
End If
End If
End If
If formatDate="1 Jan 1900" Then
formatDate="n/a"
End If
End Function
dim sDate1,sDate2
sDate1="12-31-06"
sDate2="07/11/2006"
sDate2="26-12-2006"
Response.Write ("DEFAULT Session.LCID=" & Session.LCID)
Response.Write ("<BR/>")
Response.Write ("Date1=" & sdate1 & ". formatDate(" & sdate1 & ") ='" &
formatDate(sdate1) & "'")
Response.Write ("<BR/>")
Response.Write ("Date2=" & sdate2 & ". formatDate(" & sdate2 & ") ='" &
formatDate(sdate2) & "'")
session.LCID=1033
Response.Write ("<BR/>")
Response.Write ("<BR/>")
Response.Write ("Session.LCID=" & Session.LCID)
Response.Write ("<BR/>")
Response.Write ("Date1=" & sdate1 & ". formatDate(" & sdate1 & ") ='" &
formatDate(sdate1) & "'")
Response.Write ("<BR/>")
Response.Write ("Date2=" & sdate2 & ". formatDate(" & sdate2 & ") ='" &
formatDate(sdate2) & "'")
session.LCID=2057
Response.Write ("<BR/>")
Response.Write ("<BR/>")
Response.Write ("Session.LCID=" & Session.LCID)
Response.Write ("<BR/>")
Response.Write ("Date1=" & sdate1 & ". formatDate(" & sdate1 & ") ='" &
formatDate(sdate1) & "'")
Response.Write ("<BR/>")
Response.Write ("Date2=" & sdate2 & ". formatDate(" & sdate2 & ") ='" &
formatDate(sdate2) & "'")
%>
<P> </P>
</BODY>
</HTML>
OUTPUT################################
DEFAULT Session.LCID=2057
Date1=12-31-06. formatDate(12-31-06) ='31 Dec 2006'
Date2=26-12-2006. formatDate(26-12-2006) ='26 Dec 2006'
Session.LCID=1033
Date1=12-31-06. formatDate(12-31-06) ='31 Dec 2006'
Date2=26-12-2006. formatDate(26-12-2006) ='26 Dec 2006'
Session.LCID=2057
Date1=12-31-06. formatDate(12-31-06) ='31 Dec 2006'
Date2=26-12-2006. formatDate(26-12-2006) ='26 Dec 2006'
/OUTPUT###################################
Notice how it uses the FIRST part of sDate1 to return the day, but the
SECOND part of sDate2
I have tried fiddling with the Locale settings, but whatever they are,
Day("12/26/2006") always returns "26".
Can anyone explain, and hopefully suggest what to do ?
Thanks in advance
I'm having a hard time with the Day() function. Basically, it appears
to be picking and choosing which part of a date string it uses to
return the result ...
heres some code :
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<%
Function formatDate(dDate)
formatDate=""
If IsNull(dDate) or Trim(dDate)="" Then
Else If IsDate(dDate) Then
If dDate<CDate("January 1, 1901") Then
formatDate=" - - "
Else formatDate=Day(dDate) & " " & MonthName(Month(dDate), true) &
" " & year(dDate)
End If
End If
End If
If formatDate="1 Jan 1900" Then
formatDate="n/a"
End If
End Function
dim sDate1,sDate2
sDate1="12-31-06"
sDate2="07/11/2006"
sDate2="26-12-2006"
Response.Write ("DEFAULT Session.LCID=" & Session.LCID)
Response.Write ("<BR/>")
Response.Write ("Date1=" & sdate1 & ". formatDate(" & sdate1 & ") ='" &
formatDate(sdate1) & "'")
Response.Write ("<BR/>")
Response.Write ("Date2=" & sdate2 & ". formatDate(" & sdate2 & ") ='" &
formatDate(sdate2) & "'")
session.LCID=1033
Response.Write ("<BR/>")
Response.Write ("<BR/>")
Response.Write ("Session.LCID=" & Session.LCID)
Response.Write ("<BR/>")
Response.Write ("Date1=" & sdate1 & ". formatDate(" & sdate1 & ") ='" &
formatDate(sdate1) & "'")
Response.Write ("<BR/>")
Response.Write ("Date2=" & sdate2 & ". formatDate(" & sdate2 & ") ='" &
formatDate(sdate2) & "'")
session.LCID=2057
Response.Write ("<BR/>")
Response.Write ("<BR/>")
Response.Write ("Session.LCID=" & Session.LCID)
Response.Write ("<BR/>")
Response.Write ("Date1=" & sdate1 & ". formatDate(" & sdate1 & ") ='" &
formatDate(sdate1) & "'")
Response.Write ("<BR/>")
Response.Write ("Date2=" & sdate2 & ". formatDate(" & sdate2 & ") ='" &
formatDate(sdate2) & "'")
%>
<P> </P>
</BODY>
</HTML>
OUTPUT################################
DEFAULT Session.LCID=2057
Date1=12-31-06. formatDate(12-31-06) ='31 Dec 2006'
Date2=26-12-2006. formatDate(26-12-2006) ='26 Dec 2006'
Session.LCID=1033
Date1=12-31-06. formatDate(12-31-06) ='31 Dec 2006'
Date2=26-12-2006. formatDate(26-12-2006) ='26 Dec 2006'
Session.LCID=2057
Date1=12-31-06. formatDate(12-31-06) ='31 Dec 2006'
Date2=26-12-2006. formatDate(26-12-2006) ='26 Dec 2006'
/OUTPUT###################################
Notice how it uses the FIRST part of sDate1 to return the day, but the
SECOND part of sDate2
I have tried fiddling with the Locale settings, but whatever they are,
Day("12/26/2006") always returns "26".
Can anyone explain, and hopefully suggest what to do ?
Thanks in advance