datevalue() ignores short date format 
Author Message
 datevalue() ignores short date format

I'm running ie4 sp1 on NT and the datevalue VBScript function seems to
assume mm/dd/yy short date format.
Under control panel/regional settings it is set to dd/mm/yyyy

Here is the code I am using.

    <script language=vbscript>
        tmpdate="25-feb-01"
        newdate=datevalue(tmpdate)
        msgbox "newdate "& newdate &" tmpdate "&tmpdate

        tmpdate="25-02-01"
        newdate=datevalue(tmpdate)
        msgbox "newdate "& newdate &" tmpdate "&tmpdate
    </script>

cDate() produces the same results.
I've tried this code on win95 and it works ok.
Also the same code works just fine using wsh which suprised me because
I thought they used the same script engine.

Any clues would be appreciated.



Fri, 20 Jul 2001 03:00:00 GMT  
 datevalue() ignores short date format
Check the "Languages..." setting on the General tab of Internet Options.  I
haven't verified this, but it could default to mm/dd/yy if the setting is US
English.

Ken

Quote:

>I'm running ie4 sp1 on NT and the datevalue vbscript function seems to
>assume mm/dd/yy short date format.
>Under control panel/regional settings it is set to dd/mm/yyyy

>Here is the code I am using.

>    <script language=vbscript>
> tmpdate="25-feb-01"
> newdate=datevalue(tmpdate)
> msgbox "newdate "& newdate &" tmpdate "&tmpdate

> tmpdate="25-02-01"
> newdate=datevalue(tmpdate)
> msgbox "newdate "& newdate &" tmpdate "&tmpdate
>    </script>

>cDate() produces the same results.
>I've tried this code on win95 and it works ok.
>Also the same code works just fine using wsh which suprised me because
>I thought they used the same script engine.

>Any clues would be appreciated.



Fri, 20 Jul 2001 03:00:00 GMT  
 datevalue() ignores short date format
IE tells the script engine "Assume that you are on a standard US English
machine".  That is so that you can write code on your web pages and know
that it is going to work everywhere.  Consider what would happen if you had
code like this:

x = "12.34"
MsgBox  x + 10

This would attempt to turn the string "12.34" into the number 12.34.  If you
were on an American machine, it would work, but if you were on a German
machine, that would have to be "12,34", not "12.34".  It makes it nigh
impossible to write portable code if you use the default locale.  So IE
imposes restrictions on the locale that WSH does not.

Unfortunately, as you discovered, it also makes localization difficult.  For
that reason, we're adding a function called "SetLocale" in VBScript v5.0
that overrides IE's locale setting.  That way if you know what you're doing,
you can force the locale to be, say, German.

Eric


Quote:
> I'm running ie4 sp1 on NT and the datevalue vbscript function seems to
> assume mm/dd/yy short date format.
> Under control panel/regional settings it is set to dd/mm/yyyy

> Here is the code I am using.

>     <script language=vbscript>
> tmpdate="25-feb-01"
> newdate=datevalue(tmpdate)
> msgbox "newdate "& newdate &" tmpdate "&tmpdate

> tmpdate="25-02-01"
> newdate=datevalue(tmpdate)
> msgbox "newdate "& newdate &" tmpdate "&tmpdate
>     </script>

> cDate() produces the same results.
> I've tried this code on win95 and it works ok.
> Also the same code works just fine using wsh which suprised me because
> I thought they used the same script engine.

> Any clues would be appreciated.



Fri, 20 Jul 2001 03:00:00 GMT  
 datevalue() ignores short date format
So, this feature, will americanize my dates on NT systems but not on
Win95. how portable is that?

This situation make all of the date functions unusable.
Currently, if I enter 25-2-01 it assumes a year of 2025 (winnt only)
but if I enter 25-2-2001 it just swaps my month and year. It seems
like a lot of extra effort not to mention error prone to write a
string_to_date routine.

Any recommendations on how to allow date entry using the locale
settings?


Quote:
>IE tells the script engine "Assume that you are on a standard US English
>machine".  That is so that you can write code on your web pages and know
>that it is going to work everywhere.  Consider what would happen if you had
>code like this:

>x = "12.34"
>MsgBox  x + 10

>This would attempt to turn the string "12.34" into the number 12.34.  If you
>were on an American machine, it would work, but if you were on a German
>machine, that would have to be "12,34", not "12.34".  It makes it nigh
>impossible to write portable code if you use the default locale.  So IE
>imposes restrictions on the locale that WSH does not.

>Unfortunately, as you discovered, it also makes localization difficult.  For
>that reason, we're adding a function called "SetLocale" in VBScript v5.0
>that overrides IE's locale setting.  That way if you know what you're doing,
>you can force the locale to be, say, German.

>Eric



>> I'm running ie4 sp1 on NT and the datevalue vbscript function seems to
>> assume mm/dd/yy short date format.
>> Under control panel/regional settings it is set to dd/mm/yyyy

>> Here is the code I am using.

>>     <script language=vbscript>
>> tmpdate="25-feb-01"
>> newdate=datevalue(tmpdate)
>> msgbox "newdate "& newdate &" tmpdate "&tmpdate

>> tmpdate="25-02-01"
>> newdate=datevalue(tmpdate)
>> msgbox "newdate "& newdate &" tmpdate "&tmpdate
>>     </script>

>> cDate() produces the same results.
>> I've tried this code on win95 and it works ok.
>> Also the same code works just fine using wsh which suprised me because
>> I thought they used the same script engine.

>> Any clues would be appreciated.



Fri, 20 Jul 2001 03:00:00 GMT  
 datevalue() ignores short date format
Hi Eric and All,

 that's very nice to hear about that new feature. More an
admin as an programmer, we cannot always be on top of
all this news......and cannot test each new beta.

 We had lot's, lot's of trouble here in Germany, because we
use all server software in english (because of much
higher availability of updates and patches) but - naturally -
have german software on all clients. If we generate
static html from WSH, or ASP page we have much trouble
with date recognition and translation.

Best regards,
Manfred Braun

(Private)
Lange Roetterstrasse 7
D68167 Mannheim
Germany


Phone : +49-621-37 53 86
(Remove the anti-spam-underscore to mail me!)


Quote:
>IE tells the script engine "Assume that you are on a standard US English
>machine".  That is so that you can write code on your web pages and know
>that it is going to work everywhere.  Consider what would happen if you had
>code like this:

>x = "12.34"
>MsgBox  x + 10

>This would attempt to turn the string "12.34" into the number 12.34.  If you
>were on an American machine, it would work, but if you were on a German
>machine, that would have to be "12,34", not "12.34".  It makes it nigh
>impossible to write portable code if you use the default locale.  So IE
>imposes restrictions on the locale that WSH does not.

>Unfortunately, as you discovered, it also makes localization difficult.  For
>that reason, we're adding a function called "SetLocale" in VBScript v5.0
>that overrides IE's locale setting.  That way if you know what you're doing,
>you can force the locale to be, say, German.

>Eric



>> I'm running ie4 sp1 on NT and the datevalue vbscript function seems to
>> assume mm/dd/yy short date format.
>> Under control panel/regional settings it is set to dd/mm/yyyy

>> Here is the code I am using.

>>     <script language=vbscript>
>> tmpdate="25-feb-01"
>> newdate=datevalue(tmpdate)
>> msgbox "newdate "& newdate &" tmpdate "&tmpdate

>> tmpdate="25-02-01"
>> newdate=datevalue(tmpdate)
>> msgbox "newdate "& newdate &" tmpdate "&tmpdate
>>     </script>

>> cDate() produces the same results.
>> I've tried this code on win95 and it works ok.
>> Also the same code works just fine using wsh which suprised me because
>> I thought they used the same script engine.

>> Any clues would be appreciated.



Fri, 27 Jul 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. datevalue() ignores short date format

2. FormatDateTime short date format problem

3. Short Date Formatting

4. CLIENT SIDE SHORT DATE FORMAT

5. Date format vbLongDate ignores server's regional settings

6. Set date format to short in VBA

7. Short Date Format?

8. changing the short date format on startup

9. API - Short Date Format

10. Wrong short date format

11. Programmatically change short date format.

12. How Can I Change the Short Date Format At Regional Settings in Control Panel

 

 
Powered by phpBB® Forum Software