?
Solved

type mismatch on date function when using LCID 1037

Posted on 2004-08-01
24
Medium Priority
?
718 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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
 
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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

771 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