Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Known bug in CStr (Date ()) in WSH 5.7?

Reply
 
Old 07-11-2008   #1 (permalink)
Tony Longson


 
 

Known bug in CStr (Date ()) in WSH 5.7?

Hi folks

I've recently updated my XP laptop to SP3 which has uplifted WSH to v5.7 and
this has introduced a bug regarding the Date () function. When the result is
being converted to a string, it doesn't use the correct local format, but
seems to default to US format instead. Here in the UK the standard format is
DD/MM/YYYY. Here is some example code:

WScript.Echo Date ()
WScript.Echo ““ & Date ()
WScript.Echo CStr (Date ())

Under 5.6 this produces the correct output:

Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

04/07/2008
04/07/2008
04/07/2008

Under WSH 5.7 the output is:

Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

04/07/2008
7/4/2008
7/4/2008

This happens in both cscript.exe and wscript.exe.

Is this a known bug? The main problem I have with it is that any WMI queries
using the date either fail or return the wrong data.

Regards
Tony Longson.


My System SpecsSystem Spec
Old 07-11-2008   #2 (permalink)
Alexander Mueller


 
 

Re: Known bug in CStr (Date ()) in WSH 5.7?

Tony Longson schrieb:
Quote:

>
> I've recently updated my XP laptop to SP3 which has uplifted WSH to v5.7 and
> this has introduced a bug regarding the Date () function
> .... Here in the UK the standard format is
> DD/MM/YYYY. Here is some example code:
>
> WScript.Echo Date ()
> WScript.Echo ““ & Date ()
> WScript.Echo CStr (Date ())
>
> Under 5.6 this produces the correct output:
Quote:

> 04/07/2008
> 04/07/2008
> 04/07/2008
>
> Under WSH 5.7 the output is:
>
>
> 04/07/2008
> 7/4/2008
> 7/4/2008
This reply won't probably help you but here on XP SP3 WSH 5.7 with
german locale settings with DD.MM.YYYY as standard short date format

the output is as expected:

11.07.2008
11.07.2008
11.07.2008


It might help to test WSH 5.7 on some other machines with UK locale
to see if it is WSH 5.7, that fails or some system DLL or whatever.

Quote:

> This happens in both cscript.exe and wscript.exe.
>
> Is this a known bug? The main problem I have with it is that any WMI queries
> using the date either fail or return the wrong data.
Actually you should never rely on an automated date to string
conversion. It's much safer to use date functions such as Day, Month,
DatePart, FormatDatetime etc to build a date string properly formatted.

MfG,
Alex
My System SpecsSystem Spec
Old 07-11-2008   #3 (permalink)
Dr J R Stockton


 
 

Re: Known bug in CStr (Date ()) in WSH 5.7?

In microsoft.public.scripting.vbscript message <5CB5D3A1-78EA-4EC9-A6DD-
C1D4EC1C1654@xxxxxx>, Fri, 11 Jul 2008 08:49:00, Tony Longson
<Tony@xxxxxx?.microsoft.com.invalid> posted:
Quote:

>
>I've recently updated my XP laptop to SP3 which has uplifted WSH to v5.7 and
>this has introduced a bug regarding the Date () function.
I've not seen your problem; but my OS is set to YYYY-MM-DD.

WSH 5.7 does NOT fix the ISO Week Number bug seen in WSH 5.1 and 5.6;
details are in <URL:http://www.merlyn.demon.co.uk/vb-date2.htm#Week>,
with better code. Any comment you may have on those VBS pages would be
welcome.

My general recommendation is never to use conversion code of US origin
for converting to or from strings in non-US format; they are not
trustworthy - as you will recall from their general attitude towards tea
and cricket. Use DateSerial and TimeSerial to generate CDates; the
extra time taken in coding substringing will be repaid (though you won't
recognise it) on the first occasion on which trusting system conversion
would have failed.

In general, use locality-independent primitives in a locality-dependent
manner, unless you MUST respond to OS settings.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
My System SpecsSystem Spec
Old 07-12-2008   #4 (permalink)
Dr J R Stockton


 
 

Re: Known bug in CStr (Date ()) in WSH 5.7?

On Jul 11, 4:49*pm, Tony Longson <Tony
Long...@xxxxxx> wrote:
Quote:

> Hi folks
>
> I've recently updated my XP laptop to SP3 which has uplifted WSH to v5.7 and
> this has introduced a bug regarding the Date () function. When the resultis
> being converted to a string, it doesn't use the correct local format, but
> seems to default to US format instead. Here in the UK the standard formatis
> DD/MM/YYYY.
NOT confirmed by test here. I get what I ought to get (with VBscript
5.7 in a local Web page). Nevertheless, my previous comment still
applies.

--
(c) John Stockton, near London, UK. Posting with Google.
Mail: J.R.""""""""@physics.org or (better) via Home Page at
Web: <URL:http://www.merlyn.demon.co.uk/>
FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ...



My System SpecsSystem Spec
Old 07-12-2008   #5 (permalink)
Steve


 
 

Re: Known bug in CStr (Date ()) in WSH 5.7?

Tony Longson wrote:
Quote:

> Hi folks
>
> I've recently updated my XP laptop to SP3 which has uplifted WSH to
> v5.7 and this has introduced a bug regarding the Date () function.
> When the result is being converted to a string, it doesn't use the
> correct local format, but seems to default to US format instead. Here
> in the UK the standard format is DD/MM/YYYY.
Script output is not displayed as expected when you run VBScript or
JScript scripts in Windows Vista Service Pack 1, in Windows Server 2008,
or in Windows XP Service Pack 3:
http://support.microsoft.com/?kbid=951978

Update for Windows XP (KB951978):
http://www.microsoft.com/downloads/d...DisplayLang=en

Update for Windows Vista (KB951978):
http://www.microsoft.com/downloads/d...displaylang=en

--
Steve

A great many people mistake opinions for thoughts. -Herbert V. Prochnow


My System SpecsSystem Spec
Old 07-12-2008   #6 (permalink)
Dr J R Stockton


 
 

Re: Known bug in CStr (Date ()) in WSH 5.7?

In microsoft.public.scripting.vbscript message <4877acad$0$7539$9b4e6d93
@newsspool1.arcor-online.net>, Fri, 11 Jul 2008 20:55:41, Alexander
Mueller <millerax@xxxxxx> posted:
Quote:

>Actually you should never rely on an automated date to string
>conversion. It's much safer to use date functions such as Day, Month,
>DatePart, FormatDatetime etc to build a date string properly formatted.
DatePart is not entirely reliable; see
<URL:http://www.merlyn.demon.co.uk/vb-date2.htm#WN>

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
My System SpecsSystem Spec
Old 07-15-2008   #7 (permalink)
Tony Longson


 
 

RE: Known bug in CStr (Date ()) in WSH 5.7?

Thanks for your comments folks.

The issue has now been resolved by hotfix KB951978.

Tony

"Tony Longson" wrote:
Quote:

> Hi folks
>
> I've recently updated my XP laptop to SP3 which has uplifted WSH to v5.7 and
> this has introduced a bug regarding the Date () function. When the result is
> being converted to a string, it doesn't use the correct local format, but
> seems to default to US format instead. Here in the UK the standard format is
> DD/MM/YYYY. Here is some example code:
>
> WScript.Echo Date ()
> WScript.Echo ““ & Date ()
> WScript.Echo CStr (Date ())
>
> Under 5.6 this produces the correct output:
>
> Microsoft (R) Windows Script Host Version 5.6
> Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
>
> 04/07/2008
> 04/07/2008
> 04/07/2008
>
> Under WSH 5.7 the output is:
>
> Microsoft (R) Windows Script Host Version 5.7
> Copyright (C) Microsoft Corporation. All rights reserved.
>
> 04/07/2008
> 7/4/2008
> 7/4/2008
>
> This happens in both cscript.exe and wscript.exe.
>
> Is this a known bug? The main problem I have with it is that any WMI queries
> using the date either fail or return the wrong data.
>
> Regards
> Tony Longson.
>
My System SpecsSystem Spec
Old 07-15-2008   #8 (permalink)
Alex K. Angelopoulos


 
 

Re: Known bug in CStr (Date ()) in WSH 5.7?

"Dr J R Stockton" <jrs@xxxxxx> wrote in message
news:xODJBsRgV8dIFwUM@xxxxxx
Quote:

> In microsoft.public.scripting.vbscript message <5CB5D3A1-78EA-4EC9-A6DD-
Quote:

> My general recommendation is never to use conversion code of US origin
> for converting to or from strings in non-US format; they are not
> trustworthy - as you will recall from their general attitude towards tea
> and cricket.
Oh, come now. We're always up for a good tea party.


My System SpecsSystem Spec
Old 07-15-2008   #9 (permalink)
Al Dunbar


 
 

Re: Known bug in CStr (Date ()) in WSH 5.7?


"Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
news:eEKFh4q5IHA.1592@xxxxxx
Quote:

> "Dr J R Stockton" <jrs@xxxxxx> wrote in message
> news:xODJBsRgV8dIFwUM@xxxxxx
Quote:

>> In microsoft.public.scripting.vbscript message <5CB5D3A1-78EA-4EC9-A6DD-
>
Quote:

>> My general recommendation is never to use conversion code of US origin
>> for converting to or from strings in non-US format; they are not
>> trustworthy - as you will recall from their general attitude towards tea
>> and cricket.
>
> Oh, come now. We're always up for a good tea party.
ROTFLMAO!

/Al


My System SpecsSystem Spec
Old 07-15-2008   #10 (permalink)
Al Dunbar


 
 

Re: Known bug in CStr (Date ()) in WSH 5.7?


"Dr J R Stockton" <jrs@xxxxxx> wrote in message
news:xODJBsRgV8dIFwUM@xxxxxx
Quote:

> In microsoft.public.scripting.vbscript message <5CB5D3A1-78EA-4EC9-A6DD-
Quote:

> My general recommendation is never to use conversion code of US origin
> for converting to or from strings in non-US format; they are not
> trustworthy - as you will recall from their general attitude towards tea
> and cricket.
LOL. To say nothing of them calling the american game "football" when the
ball itself is more often handled than kicked.

The story is that their English ain't so good either. But in your sentence
above you seem to have changed the subject from "conversion code of US
origin" before the semicolon to the US originators of said code after the
" - ", leaving the intended target of the intervening "they" to be just a
guess between the two.

I forget what that particular grammatical error is called; but I'll bet you
remember! ;-)

/Al


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Guid and Cstr VB Script
Date Taken and Date Modified Vista music pictures video
Modified Date used as Date Taken in Photo Gallery and Digital Imag Vista music pictures video
Photo date taken vs. file date Vista music pictures video
Blank "Date Taken / Date Modified" field in Vista Vista file management


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46