type mismatch on date function when using LCID 1037

Hi,

I am trying to localize a software written in the US and running as well in Germany and the UK.

The Hebrew Locale (1037) defines date format as dd/mm/yyyy and when writing a simple ASP page as follows, date appears in the same format:

<%
'dtDate=formatdatetime(date(), vbshortdate)
dtDate=date()
%>
<html>

<head>
</head>

<body>

Date is <%=dtDate %>

</body>

</html>

When using the formatdatetime(date(), vbshortdate) the date is displayed as "þ01/þ08/þ2004" and in debugger mode I see it gets transferred in the URL as yyyy/mm/dd. When runing any date function on it I get tyoe mismatch error.

Any ideas how to resolve this ?

BTW, I'm using client and server on the same machine, with default language Hebrew on Win XP.

thanks,

gil.

ggivatiAsked:
Who is Participating?
 
fritz_the_blankConnect With a Mentor Commented:
Okay, then be sure to close this question out by accepting the comment that helped you the most as an answer.

For details, please see:  http://www.experts-exchange.com/help.jsp#hs5

FtB
0
 
fritz_the_blankCommented:
0
 
fritz_the_blankCommented:
The other option is to manipulate the date into the format that you want it:


function formatDate(datDate)
  intYear = Year(datDate)
  intMonth = Month(datDate)
  intDay = Day(datDate)
  formatDate = intYear & "/" & intMonth & "/" & intDay
end function

You can change the last line of the function to return whatever format you want.

FtB
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
fritz_the_blankCommented:
A coule of other thoughts:

1) almost all systems understand the format yyyy/mm/dd
2) if you format dd-mmm-yyyy, i.e., 06-Jun-2004, most systems will resolve this unambiguously

FtB
0
 
ggivatiAuthor Commented:
I am trying to set LCID to 1037 and this is exactly when the date gets "reversed" from a reason I cannot understand.
Using the formatDate function you suggested may be a workaround but I'm affraid it will affect other behaviour in other pages of the application.

My preference is to try and understand why ASP reverse the date format from dd/mm/yyyy to yyyy/mm/dd when using LCID 1037.  The following code is a very simple reproduction of the problem:

<%
session.LCID=1037
dtDate=formatdatetime(date(), 2)
dtMonth=month(dtDate)
%>
<html>

<head>
</head>

<body>
Date is <%=dtDate %>
Month is <%=dtMonth %>

</body>

</html>

though it seems like a valid code, it gets type mismatch on the month parsing line
0
 
fritz_the_blankCommented:
Let me run that here so that I can see what you see. Please stand by for a minute.

FtB
0
 
fritz_the_blankCommented:
Hmn....

SessionID, ASP 0219 (0x80004005)
The specified LCID is not available.
/dev/eesample.asp, line 9
0
 
ggivatiAuthor Commented:
You probably don't have the language installed ...
0
 
fritz_the_blankCommented:
Here is the code:

<%
session.LCID=1037
dtDate=formatdatetime(date(), 2)
dtMonth=month(dtDate)
%>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
Date is <%=dtDate %>
Month is <%=dtMonth %>
</BODY>
</HTML>


Here is the error:

SessionID error 'ASP 0219 : 80004005'

Invalid LCID

/eesample.asp, line 2

The specified LCID is not available.
0
 
fritz_the_blankCommented:
I tried in on my XP with IIS and with my hosting server (Win 2K)

FtB
0
 
fritz_the_blankCommented:
Okay, since I can't see what you see, let's try a slightly different approach...

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<%
dtDate=date()
Response.write("Type Before:" & VarType(dtDate) & "<P>")
dtDate=formatdatetime(date(), 2)
Response.write("Type After" & VarType(dtDate) & "<P>")
dtMonth=month(dtDate)
Response.write("Type Month" & VarType(dtMonth) & "<P>")
%>
</BODY>
</HTML>
0
 
ggivatiAuthor Commented:
You need to have Hebrew installed. it is not installed by default on the server.
0
 
fritz_the_blankCommented:
Okay, so when I run the above, I get:

Type Before:7
Type After8

Type Month2


7 = vbDate
8=vbString
2=vbInteger

FtB
0
 
fritz_the_blankCommented:
I suspect what might be happeing here is that the raw date format you end up getting is dependent upon the regional settings of your server.

FtB
0
 
ggivatiAuthor Commented:
I still get a type mismatch on the dtMonth=month(dtDate) line. and dtDate is seen ( in visual studio debugger) "2004/08/01"
0
 
fritz_the_blankCommented:
>>My preference is to try and understand why ASP reverse the date format from dd/mm/yyyy to yyyy/mm/dd when using LCID 1037.<<

Using the LCID formats the display of your date but does not change the instrinsic format which is actually controlled by the regional settings on the server.

FtB
0
 
ggivatiAuthor Commented:
true, but setting LCID also affects the currency symbol and I will want to have the local currency used.
0
 
fritz_the_blankCommented:
That is true, but if you are going to run the code in a series of environments, then you will have to do some gymnastics with date manipulation unless all of the servers have the same regional settings.

FtB
0
 
fritz_the_blankCommented:
With this script;

HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<%
dtDate=date()
Response.write("Type Before:" & VarType(dtDate) & "<P>")
dtDate=formatdatetime(date(), 2)
Response.write("Type After" & VarType(dtDate) & "<P>")
dtMonth=month(dtDate)
Response.write("Type Month" & VarType(dtMonth) & "<P>")
%>
</BODY>
</HTML>


what probably happens is that dtDate=formatdatetime(date(), 2) produces a format that your code no longer understands as a valid date.

FtB
0
 
fritz_the_blankCommented:
So the only way that you will have the control that you really want is to use the native format for all of the coding and calculations and then use the date function that I gave you above to display things the way that you want to.

FtB
0
 
ggivatiAuthor Commented:
FtB,

Your script did do the work in most parts. I now need to enhance it a bit to accomodate the use of times as well.

10x.

Gl.
0
 
fritz_the_blankCommented:
This should put you on your way:

function forceDateTimeFormat(datDate)
  intYear = Year(datDate)
  intMonth = Month(datDate)
  intDay = Day(datDate)
  intHour = Hour(datDate)
  intMinute = Minute(datDate)
  intSecond = Second(datDate)
  forceDateTimeFormat= intYear & "/" & intMonth & "/" & intDay & " " & intHour & ":" & intMinute & ":" & intSecond
end function


Fritz the Blank
0
 
fritz_the_blankCommented:
So, did the last bit do what you needed it to?

FtB
0
 
ggivatiAuthor Commented:
Yes it did. 10x.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.