Solved

type mismatch on date function when using LCID 1037

Posted on 2004-08-01
24
696 Views
Last Modified: 2012-08-13
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.

0
Comment
Question by:ggivati
  • 17
  • 7
24 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11687902
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11687911
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11687915
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
 

Author Comment

by:ggivati
ID: 11687931
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11687954
Let me run that here so that I can see what you see. Please stand by for a minute.

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11687962
Hmn....

SessionID, ASP 0219 (0x80004005)
The specified LCID is not available.
/dev/eesample.asp, line 9
0
 

Author Comment

by:ggivati
ID: 11687979
You probably don't have the language installed ...
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11687991
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11687995
I tried in on my XP with IIS and with my hosting server (Win 2K)

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11688015
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
 

Author Comment

by:ggivati
ID: 11688016
You need to have Hebrew installed. it is not installed by default on the server.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11688030
Okay, so when I run the above, I get:

Type Before:7
Type After8

Type Month2


7 = vbDate
8=vbString
2=vbInteger

FtB
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11688037
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
 

Author Comment

by:ggivati
ID: 11688040
I still get a type mismatch on the dtMonth=month(dtDate) line. and dtDate is seen ( in visual studio debugger) "2004/08/01"
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11688043
>>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
 

Author Comment

by:ggivati
ID: 11688053
true, but setting LCID also affects the currency symbol and I will want to have the local currency used.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11688057
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11688063
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11688068
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
 

Author Comment

by:ggivati
ID: 11688146
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11688219
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11688479
So, did the last bit do what you needed it to?

FtB
0
 

Author Comment

by:ggivati
ID: 11688706
Yes it did. 10x.
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 500 total points
ID: 11688709
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now